text
stringlengths 8
6.88M
|
|---|
#include<graphics.h>
#include<constream.h>
void main(){
int driver=DETECT,mode;
clrscr();
initgraph(&driver,&mode,"\\tc\\bgi");
setcolor(4);
//rectangle(left,top,right,bottom);
line(400,410,300,140);
line(120,390,300,140);
line(400,410,120,390);
line(270,300,300,140);
line(270,300,120,390);
line(270,300,400,410);
getch();
}//end of method
|
#pragma once
#include <mpi.h>
#include "Model_MPI.hpp"
#include "boost/multi_array.hpp"
class AnalysisInterface {
public:
virtual ~AnalysisInterface();
// So here, the x1 and x2 can correspont to any 3D parametrization,
// be it k's or f's or z's or whatever.
// The Fisher Method will worry about how to use that.
virtual double Cl(int l, double x1, double x2,\
int Pk_index, int Tb_index, int q_index);
virtual double Cl_noise(int l, double x1, double x2);
virtual double Cl_foreground(int l, double x1, double x2, map<string,double> FG_param_values);
virtual double Cl_FG_deriv_analytic(int l, double x1, double x2, string param_key);
map<string,double> get_base_FG_params();
// FG parameters list
vector<string> FG_params;
string give_analysisID();
ModelInterface* model;
protected:
string analysisID;
map<string,double> FG_param_base_values;
};
/** Adding a new Method just needs to inherit from AnalysisInterface **/
/** Model used for intensity mapping **/
class IntensityMapping : public AnalysisInterface {
public:
IntensityMapping(ModelInterface* model);
IntensityMapping(ModelInterface* model, int num_params, MPI_Comm communicator);
~IntensityMapping();
double Cl(int l, double nu1, double nu2,\
int Pk_index, int Tb_index, int q_index);
double Cl_noise(int l, double nu1, double nu2);
double Cl_foreground(int l, double nu1, double nu2, map<string,double> FG_param_values);
double Cl_FG_deriv_analytic(int l, double nu1, double nu2, string param_key);
protected:
void make_Cl_interps(int lmin, int lmax, double nu_min, double nu_max, int nu_steps);
int make_Cl_interps(int lmin, int lmax, double nu_min, double nu_max, int nu_steps,\
int Pk_index, int Tb_index, int q_index);
double P(double k, double z1, double z2, double Pk_index);
double I(int l, double k, double nu_0);
double Cl_interp(int l,double nu1);
double Cl_interp(int l,double nu1, int Pk_index, int Tb_index, int q_index, int index);
bool interpolating, interpolate_large;
double calc_Cl(int l, double nu1, double nu2,\
int Pk_index, int Tb_index, int q_index);
vector<spline1dinterpolant> Clnu_interpolators;
struct Interpol{
bool computed;
spline1dinterpolant interpolator;
};
vector<CL_INTERP> Cls_interpolators_large;
//typedef boost::multi_array<Interpol,4> Interpol_Array;
//boost::array<Interpol_Array::index,4> shape = {{1,1,1,1}};
//Interpol_Array* Cls_interpolators_large;
vector<vector<vector<vector<Interpol>>>> Cls_interpolators_large2;
int num_params;
int lmax_CLASS,lmin_CLASS, nu_steps_CLASS;
double numax_CLASS,numin_CLASS;
int rank;
};
|
#pragma once
#include "core/rdma_sched.h"
#include "rdmaio.h"
#include <emmintrin.h>
#include <immintrin.h>
#include <x86intrin.h>
#include <xmmintrin.h>
//#include "../../nvm/benchs/two_sided/core.hh"
#include "../../nvm/nvm_region.hh"
using namespace nvm;
extern ::rdmaio::Arc<MemoryRegion> nvm_region;
namespace nocc {
namespace rtx {
using namespace rdmaio;
using namespace oltp;
inline usize nt_memcpy(char *src, u64 size, char *target) {
auto cur_ptr = src;
usize cur = 0;
for (cur = 0; cur < size;) {
// in 64 bytes granulaity
for (uint i = 0; i < 8; ++i) {
// I believe that compiler will unroll this
_mm_stream_pi((__m64 *)(target + cur), *((__m64 *)(src + cur)));
cur += sizeof(u64);
}
}
return cur;
}
class RpcLogger : public Logger {
public:
RpcLogger(RRpc *rpc, int log_rpc_id, int ack_rpc_id, uint64_t base_off,
int expected_store, char *local_p, int ms, int ts, int size,
int entry_size = RTX_LOG_ENTRY_SIZE)
: Logger(rpc, ack_rpc_id, base_off, expected_store, local_p, ms, ts, size,
entry_size),
log_rpc_id_(log_rpc_id) {
// register RPC if necessary
rpc->register_callback(
std::bind(&RpcLogger::log_remote_handler, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3,
std::placeholders::_4),
log_rpc_id_, true);
}
inline void log_remote(BatchOpCtrlBlock &clk, int cor_id) {
assert(clk.batch_size_ > 0);
clk.send_batch_op(rpc_handler_, cor_id, log_rpc_id_, false);
}
void log_remote_handler(int id, int cid, char *msg, void *arg) {
int size = (uint64_t)arg;
char *local_ptr = mem_.get_next_log(id,rpc_handler_->worker_id_,size);
//int thread_sz = 4096 * 16;
//char *local_ptr = (char *)(nvm_region->addr) + rpc_handler_->worker_id_ * thread_sz + 4096 * cid;
assert(size < RTX_LOG_ENTRY_SIZE && size > 0);
// memcpy(local_ptr,msg,size);
//memcpy(local_buffer + cid * MAX_MSG_SIZE, msg, size);
//assert(nt_memcpy(msg,size,local_buffer + cid * MAX_MSG_SIZE) >= size);
assert(nt_memcpy(msg,size,local_ptr) >= size);
asm volatile("sfence" : : : "memory");
//LOG(4) << "size: " << size ; sleep(1);
//LOG(4) << "write to nvm_region: " << (void *)local_ptr << ", start of the region: "
//<< nvm_region->addr; sleep(1);
char *reply_msg = rpc_handler_->get_reply_buf();
rpc_handler_->send_reply(reply_msg, 0, id, cid); // a dummy reply
}
private:
const int log_rpc_id_;
char local_buffer[MAX_MSG_SIZE * 32];
};
} // namespace rtx
} // namespace nocc
|
#ifndef TALENTS_HPP
#define TALENTS_HPP
#include <map>
#include "adventurePoints.hpp"
#include <QTableWidget>
#include <QHeaderView>
#include <QLayout>
#include <QFrame>
class TalentsGUI
{
private:
enum TalentGroupNames {
GESELLSCHAFTSTALENTE = 0,
HANDWERKSTALENTE,
KOERPERTALENTE,
KRIEGSKUNSTTALENTE,
NATURTALENTE,
WISSENSTALENTE
};
struct Talent {
QString NameTalent;
QString NamePropertyOne;
QString NamePropertyTwo;
QString NamePropertyThree;
QLabel* LabelTalent;
QLabel* LabelPropertyOne;
QLabel* LabelPropertyTwo;
QLabel* LabelPropertyThree;
QLCDNumber* LCDNumberPropertyOne;
QLCDNumber* LCDNumberPropertyTwo;
QLCDNumber* LCDNumberPropertyThree;
MySpinBox* SpinBox;
QTableWidget* TableWidget;
Talent(QString talentName = "", QString propertieOne = "", QString propertieTwo = "", QString propertieThree = "");
};
struct TalentGroup {
QString TalentGroupName;
std::vector<Talent> Data;
QTableWidget* TableWidget;
TalentGroup(QString talentGroupName = "");
};
std::map<TalentGroupNames, TalentGroup> m_TalentGUI;
QVBoxLayout* m_Layout_Talents;
QHBoxLayout* m_Layout_TopRow;
QHBoxLayout* m_Layout_BottomRow;
QFrame* m_Frame_TopRow;
QFrame* m_Frame_BottomRow;
QFrame* m_Frame_Talents;
void initTalentGroup();
void setTalentData(TalentGroupNames talentGroupName);
void initLabel();
void initLCDNumber();
void initSpinbox();
void initTableTalentData();
void initTableTalentGroup();
void initGUI();
void setTableTalentData(QTableWidget* obj, int columns, int rows);
void setTableTalentGroup(QTableWidget *obj, QStringList header, int rows);
void checkPropertyType(QLabel* property, QLCDNumber* display, std::vector<int> values);
void addLabelToTalentDataTable(QTableWidget* obj, std::vector<QLabel*> label);
void addLCDNumberToTalentDataTable(QTableWidget* obj, std::vector<QLCDNumber*> lcdNumber);
void addSpinBoxToTalentDataTable(QTableWidget* obj, QSpinBox* spinBox);
void addTalentDataToTalentGroupTable(QTableWidget* obj, QTableWidget* talentData, int row);
void mergeTalentDataTableCells(QTableWidget* obj);
public:
TalentsGUI();
QFrame* getFrame() const;
void setPropertyValues(int ch, int ge, int in, int kk, int kl, int ko, int mu, int se);
};
#endif // TALENTS_HPP
|
#include <cstdio>
#include <iostream>
using namespace std;
struct RandomListNode{
int label;
RandomListNode *next, *random;
RandomListNode(int x): label(x), next(NULL), random(NULL){}
};
RandomListNode *copyRandomList(RandomListNode *head){
if(head == NULL) return NULL;
RandomListNode *p = head;
while(p != NULL){
RandomListNode *temp = new RandomListNode(p->label);
temp->next = p->next;
p->next = temp;
p = temp->next;
}
p = head;
RandomListNode *cp = head->next;
RandomListNode *res = cp;
while(cp->next != NULL){
if(p->random == NULL) cp->random = NULL;
else cp->random = p->random->next;
p = p->next->next;
cp = cp->next->next;
}
if(p->random == NULL) cp->random = NULL;
else cp->random = p->random->next;
p = head;
cp = head->next;
while(cp->next != NULL){
p->next = cp->next;
cp->next = cp->next->next;
p = p->next;
cp = cp->next;
}
p->next = NULL;
return res;
}
int main(){
RandomListNode *p = new RandomListNode(-1);
RandomListNode *q = new RandomListNode(-1);
RandomListNode *k = new RandomListNode(-2);
p->next = q;
q->next = k;
RandomListNode *n = copyRandomList(p);
while(n!= NULL){
cout << n->label<<endl;
n = n->next;
}
}
|
#include "pch.h"
#include "tchar.h"
#include <aced.h>
#include <rxregsvc.h>
void initApp();
void unloadApp();
void helloWorld();
void initApp()
{
acedRegCmds->addCommand(_T("HELLOWORLD_COMMANDS"),
_T("Hello"),
_T("Bonjour"),
ACRX_CMD_TRANSPARENT,
helloWorld);
}
void unloadApp()
{
acedRegCmds->removeGroup(_T("HELLOWORLD_COMMANDS"));
}
void helloWorld()
{
acutPrintf(_T("Hello, World!"));
}
extern "C"
AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
switch (msg)
{
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(pkt);
acrxRegisterAppMDIAware(pkt);
initApp();
break;
case AcRx::kUnloadAppMsg:
unloadApp();
break;
default:
break;
}
return AcRx::kRetOK;
}
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
**
** Copyright (C) 2006-2007 Opera Software AS. All rights reserved.
**
** This file is part of the Opera web browser. It may not be distributed
** under any circumstances.
**
*/
#include "core/pch.h"
#ifdef SVG_SUPPORT
#include "modules/svg/src/svgpch.h"
// #ifdef SVG_SUPPORT_NAVIGATION
#include "modules/svg/src/AttrValueStore.h"
#include "modules/svg/src/SVGElementStateContext.h"
#include "modules/svg/src/SVGDocumentContext.h"
#include "modules/svg/src/SVGManagerImpl.h"
#include "modules/svg/src/SVGUtils.h"
#include "modules/svg/src/SVGNavigation.h"
#include "modules/layout/cascade.h"
/* static */
BOOL SVGNavigation::NavRefToElement(HTML_Element* elm, Markup::AttrType attr,
HTML_Element*& preferred_next_elm)
{
if (!AttrValueStore::HasObject(elm, attr, NS_IDX_SVG))
return FALSE;
SVGNavRef* navref = NULL;
AttrValueStore::GetNavRefObject(elm, attr, navref);
if (navref)
{
HTML_Element* next_elm = NULL;
SVGNavRef::NavRefType nrt = navref->GetNavType();
if (nrt == SVGNavRef::SELF)
{
next_elm = elm; // Same as current
}
else if (nrt == SVGNavRef::URI)
{
SVGURL nav_elm_url;
if (OpStatus::IsSuccess(nav_elm_url.SetURL(navref->GetURI(), URL())))
{
if (SVGDocumentContext* doc_ctx = AttrValueStore::GetSVGDocumentContext(elm))
{
URL fullurl = nav_elm_url.GetURL(doc_ctx->GetURL(), elm);
next_elm = (fullurl == doc_ctx->GetURL()) ?
SVGUtils::FindElementById(doc_ctx->GetLogicalDocument(), fullurl.UniRelName()) :
NULL;
}
}
}
// Fall-through for ::AUTO
if (next_elm != NULL)
{
preferred_next_elm = next_elm;
return TRUE;
}
}
return FALSE;
}
/* static */
BOOL SVGNavigation::FindElementInDirection(HTML_Element* elm, int direction, int nway,
HTML_Element*& preferred_next_elm)
{
OP_ASSERT(nway == 2 || nway == 4 || nway == 8); // These are what we can accommodate
Markup::AttrType attr;
if (nway == 2)
{
attr = (direction / 180) ? Markup::SVGA_NAV_NEXT : Markup::SVGA_NAV_PREV;
}
else
{
// Quantize angle
int quant_dir = (((direction + (360/nway)/2) / (360/nway)) % nway) * (360/nway);
attr = Markup::SVGA_NAV_DOWN;
switch (quant_dir)
{
case 0: attr = Markup::SVGA_NAV_RIGHT; break;
case 45: attr = Markup::SVGA_NAV_UP_RIGHT; break;
case 90: attr = Markup::SVGA_NAV_UP; break;
case 135: attr = Markup::SVGA_NAV_UP_LEFT; break;
case 180: attr = Markup::SVGA_NAV_LEFT; break;
case 225: attr = Markup::SVGA_NAV_DOWN_LEFT; break;
case 270: attr = Markup::SVGA_NAV_DOWN; break;
case 315: attr = Markup::SVGA_NAV_DOWN_RIGHT; break;
default:
OP_ASSERT(!"Bad direction!");
break;
}
}
return NavRefToElement(elm, attr, preferred_next_elm);
}
OP_STATUS SVGAreaIterator::Init(HTML_Element* start_elm, const OpRect* search_area)
{
m_doc_ctx = AttrValueStore::GetSVGDocumentContext(start_elm);
if (!m_doc_ctx)
return OpStatus::ERR;
VisualDevice* vd = m_doc_ctx->GetVisualDevice();
if (!vd)
return OpStatus::ERR;
m_current_elm = start_elm;
m_next_found = m_prev_found = FALSE;
m_search_area.Empty();
if (search_area)
{
m_search_area = *search_area;
m_search_area = vd->ScaleToScreen(m_search_area);
#ifdef PIXEL_SCALE_RENDERING_SUPPORT
m_search_area = TO_DEVICE_PIXEL(vd->GetVPScale(), m_search_area);
#endif // PIXEL_SCALE_RENDERING_SUPPORT
}
return OpStatus::OK;
}
OP_STATUS SVGAreaIterator::TestVisible(HTML_Element* test_elm, HTML_Element* layouted_elm)
{
SVGElementContext* elm_ctx = AttrValueStore::GetSVGElementContext(test_elm);
// Enough for 'switch' handling ?
if (!elm_ctx)
return OpSVGStatus::SKIP_ELEMENT /* SUBTREE ? */;
if (elm_ctx->IsFilteredByRequirements())
return OpSVGStatus::SKIP_SUBTREE;
const OpRect screen_extents = elm_ctx->GetScreenExtents();
if (!m_search_area.IsEmpty() && !screen_extents.Intersecting(m_search_area))
// Not in search area
return OpSVGStatus::SKIP_SUBTREE;
AutoDeleteHead prop_list;
HLDocProfile* hld_profile = m_doc_ctx->GetHLDocProfile();
if (!hld_profile)
return OpStatus::ERR;
LayoutProperties* elm_props = LayoutProperties::CreateCascade(layouted_elm,
prop_list, LAYOUT_WORKPLACE(hld_profile));
if (!elm_props)
return OpStatus::ERR_NO_MEMORY;
if (SVGUtils::IsDisplayNone(layouted_elm, elm_props))
return OpSVGStatus::SKIP_SUBTREE;
return OpStatus::OK;
}
OP_STATUS SVGAreaIterator::TestRelevantForDisplay(HTML_Element* layouted_elm)
{
if (layouted_elm->GetNsType() != NS_SVG)
return OpSVGStatus::SKIP_SUBTREE;
Markup::Type type = layouted_elm->Type();
if (SVGUtils::IsAlwaysIrrelevantForDisplay(type))
return OpSVGStatus::SKIP_SUBTREE;
return OpStatus::OK;
}
OP_STATUS SVGAreaIterator::TestElement(HTML_Element* test_elm, HTML_Element* layouted_elm)
{
if (layouted_elm->IsText())
return OpSVGStatus::SKIP_ELEMENT;
RETURN_IF_ERROR(TestRelevantForDisplay(layouted_elm));
return TestVisible(test_elm, layouted_elm);
}
BOOL SVGAreaIterator::Step(BOOL forward)
{
HTML_Element* next_elm = m_current_elm;
while (next_elm)
{
HTML_Element* layouted_elm = SVGUtils::GetElementToLayout(next_elm);
OP_STATUS status = TestElement(next_elm, layouted_elm);
switch (status)
{
default: // In case of error
case OpSVGStatus::SKIP_ELEMENT:
next_elm = forward ? next_elm->Next() : next_elm->Prev();
break;
case OpSVGStatus::SKIP_SUBTREE:
next_elm = forward ?
static_cast<HTML_Element*>(next_elm->NextSibling()) :
static_cast<HTML_Element*>(next_elm->PrevSibling());
break;
case OpStatus::OK:
// Yay! Found one
m_current_elm = next_elm;
return TRUE;
}
}
// Nothing found
m_current_elm = next_elm;
return FALSE;
}
HTML_Element* SVGAreaIterator::Next()
{
if (!m_current_elm && !m_prev_found)
m_current_elm = m_doc_ctx->GetSVGRoot();
else if (m_current_elm)
m_current_elm = m_current_elm->Next();
m_next_found = Step(TRUE /* forward */);
return m_next_found ? m_current_elm : NULL;
}
HTML_Element* SVGAreaIterator::Prev()
{
if (!m_current_elm && !m_next_found)
m_current_elm = m_doc_ctx->GetSVGRoot()->LastChild();
else if (m_current_elm)
m_current_elm = m_current_elm->Prev();
m_prev_found = Step(FALSE /* backward */);
return m_prev_found ? m_current_elm : NULL;
}
OP_STATUS SVGFocusIterator::TestElement(HTML_Element* test_elm, HTML_Element* layouted_elm)
{
if (layouted_elm->IsText())
return OpSVGStatus::SKIP_ELEMENT;
RETURN_IF_ERROR(TestRelevantForDisplay(layouted_elm));
if (!g_svg_manager_impl->IsFocusableElement(m_doc_ctx->GetDocument(), layouted_elm))
return OpSVGStatus::SKIP_ELEMENT;
return TestVisible(test_elm, layouted_elm);
}
#ifdef SEARCH_MATCHES_ALL
OP_STATUS SVGHighlightUpdateIterator::Init(HTML_Element* start_elm, SelectionElm* first_hit)
{
m_doc_ctx = AttrValueStore::GetSVGDocumentContext(start_elm);
if (!m_doc_ctx)
return OpStatus::ERR;
m_current_elm = start_elm;
m_next_found = m_prev_found = FALSE;
m_current_hit = first_hit;
return OpStatus::OK;
}
OP_STATUS SVGHighlightUpdateIterator::TestElement(HTML_Element* test_elm, HTML_Element* layouted_elm)
{
if(!m_doc_ctx->GetSVGImage()->IsInteractive())
return OpSVGStatus::SKIP_SUBTREE;
if(!m_current_hit)
return OpSVGStatus::SKIP_ELEMENT;
if (layouted_elm->IsText())
{
if(layouted_elm == m_current_hit->GetSelection()->GetStartElement())
{
m_current_hit = (SelectionElm*)m_current_hit->Suc();
return OpStatus::OK;
}
}
RETURN_IF_ERROR(TestRelevantForDisplay(layouted_elm));
SVGElementContext* elm_ctx = AttrValueStore::GetSVGElementContext(test_elm);
if (!elm_ctx)
return OpSVGStatus::SKIP_ELEMENT /* SUBTREE ? */;
if (!SVGUtils::IsTextClassType(layouted_elm->Type()) &&
!SVGUtils::IsContainerElement(test_elm))
return OpSVGStatus::SKIP_SUBTREE;
RETURN_IF_ERROR(TestVisible(test_elm, layouted_elm));
return OpSVGStatus::SKIP_ELEMENT;
}
#endif // SEARCH_MATCHES_ALL
#ifdef RESERVED_REGIONS
OP_STATUS SVGReservedRegionIterator::TestElement(HTML_Element* test_elm, HTML_Element* layouted_elm)
{
if (layouted_elm->IsText())
return OpSVGStatus::SKIP_ELEMENT;
RETURN_IF_ERROR(TestRelevantForDisplay(layouted_elm));
HLDocProfile* hld_profile = m_doc_ctx->GetHLDocProfile();
if (!hld_profile)
return OpStatus::ERR;
BOOL has_reserved_handler = FALSE;
for (int i = 0; g_reserved_region_types[i] != DOM_EVENT_NONE && !has_reserved_handler; i++)
if (layouted_elm->HasEventHandler(hld_profile->GetFramesDocument(), g_reserved_region_types[i], FALSE))
has_reserved_handler = TRUE;
if (!has_reserved_handler)
return OpSVGStatus::SKIP_ELEMENT;
return TestVisible(test_elm, layouted_elm);
}
#endif // RESERVED_REGIONS
// #endif // SVG_SUPPORT_NAVIGATION
#endif // SVG_SUPPORT
|
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
int n, q;
cin >> n >> q;
ll s[n];
cin >> s[0];
for (int i = 1; i < n; ++i) {
ll a;
cin >> a;
s[i] = s[i - 1] + a;
}
ll sum = 0;
for (int i = 0; i < q; ++i) {
ll k;
cin >> k;
sum += k;
if (upper_bound(s, s + n, sum) == s + n) sum = 0;
cout << s + n - upper_bound(s, s + n, sum) << endl;
}
return 0;
}
|
#include<iostream>
#include<stdlib.h>
#include<unistd.h>
#include<fstream>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<string.h>
using namespace std;
#define PORT 8822
#define SERVERADD "127.0.0.1"
void die(char *s)
{
perror(s);
exit(1);
}
int main()
{
int sockfd;
//create socket
if((sockfd = socket(AF_INET,SOCK_STREAM,0))==-1)
{
die("Socket Error");
}
// define structure
struct sockaddr_in server;
server.sin_family = AF_INET;
server.sin_port = htons(PORT);
server.sin_addr.s_addr = inet_addr(SERVERADD);
int m = connect(sockfd,(struct sockaddr *)&server,sizeof(server));
int msg_len;
char a[10];
bzero((char *)a,sizeof(a));
cout<<"Enter num 1 \n";
cin>> a;
msg_len = send(sockfd,a,9,0);
char b[10];
bzero((char *)b,sizeof(b));
cout<<"Enter num 2 \n";
cin>> b;
msg_len = send(sockfd,b,9,0);
char op[2];
bzero((char *)op,sizeof(op));
cout<<"Enter Operataor\n";
cin>> op;
msg_len = send(sockfd,op,2,0);
char ans[10];
bzero((char *)ans,sizeof(ans));
int r = recv(sockfd,ans,9,0);
cout<<"ANSWER from SERVER" << ans;
return 0;
}
|
/*
MATH578a Spring 2016 Unit2 HW1 - Liana Engie
Purpose: Implementation of Boyer-Moore algorithm for pattern matching.
Input:
P, pattern
T, fasta file containing text string to be matched against
Output:
All starting positions of substrings in T that exactly match P
*/
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
#include <algorithm>
using namespace std;
struct Rs{
vector<size_t> a;
vector<size_t> c;
vector<size_t> g;
vector<size_t> t;
} Rlist;
static void create_Rlist(const string &P, Rs &Rlist){
for(int i=P.size()-1; i>=0; i--){
if(P[i]=='A'){
Rlist.a.push_back(i);
}
else if(P[i]=='C'){
Rlist.c.push_back(i);
}
else if(P[i]=='G'){
Rlist.g.push_back(i);
}
else if(P[i]=='T'){
Rlist.t.push_back(i);
}
}
}
static int lookupR(Rs &Rlist, int pos, char bp){ //This is a messy program
size_t j = 0;
int newshift = pos;
if(bp=='A' && !Rlist.a.empty()){
while(Rlist.a[j]>=pos && (j<Rlist.a.size())){
newshift = Rlist.a[j], ++j;
}
} else if(bp=='C' && !Rlist.c.empty()){
while(Rlist.c[j]>=pos && (j<Rlist.c.size())){
newshift = Rlist.c[j], ++j;
}
} else if(bp=='G' && !Rlist.g.empty()){
while(Rlist.g[j]>=pos && (j<Rlist.g.size())){
newshift = Rlist.g[j], ++j;
}
}else if(bp=='T' && !Rlist.t.empty()) {
while(Rlist.t[j]>=pos && (j<Rlist.t.size())){
newshift = Rlist.t[j], ++j;
}
}else{
newshift = pos-1;
}
return newshift;
}
static size_t
match(const string &s, size_t q, const size_t n, size_t &comparisons) {
for (size_t i = n; max(q, i) < s.length() &&
(s[i]==s[q]); ++i, ++q, ++comparisons);
return q;
}
static void reverseZ(vector<size_t> &N, const string &P, size_t &comparisons){
const size_t n = P.size();
string Pr(n, ' ');
for(size_t k=0;k<n;++k){
Pr[n-k-1] = P[k];
}
vector<size_t> Z(n,0);
size_t l = 0, r = 0;
for (size_t k = 1; k < n; ++k) {
if (k >= r) {
Z[k] = match(Pr, 0, k, comparisons);
if (Z[k] > 0) {
r = k + Z[k];
l = k;
}
}
else {
const size_t k_prime = k - l;
const size_t beta_len = r - k;
if (Z[k_prime] < beta_len) {
Z[k] = Z[k_prime];
}
else {
const size_t q = match(Pr, r, beta_len, comparisons);
Z[k] = q - k;
r = q;
l = k;
}
}
}
for(int i =0;i<n;++i){
N[i] = Z[n-i-1];
}
}
static void good_suffix(vector<int> &Lprime,const vector<size_t> &N, const size_t n){
for(int j = 0; j < n; ++j){ //why not n-2?
int i = n - N[j]-1; //checked, but I'm still not sure
Lprime[i] = j;
}
}
static void sufpref(vector<int> &lprime,const vector<size_t> &N, const size_t n){
//largest suffix of P[i...n] that is also a prefix of P
int i = 0;
int j = n-1;
while(j >= 0 && i < n){
if(N[j]==j+1){
while(j <= n-i+1 && i < n){
lprime[i] = j+1;
i++;
}
}
j--;
}
}
static void
read_fasta_file_single_sequence(const string &filename, string &T) {
ifstream in(filename.c_str());
string line;
//streampos filesize = filename.tellg();
line.reserve(3e8);
in >> line;
while (in >> line)
T.append(line);
}
int main(int argc, const char * const argv[]) {
if (argc != 3) {
cerr << "usage: " << argv[0] << " <PATTERN> <FASTA-FILE>" << endl;
return EXIT_FAILURE;
}
const string P(argv[1]), filename(argv[2]);
const size_t n = P.length();
string T;
read_fasta_file_single_sequence(filename, T);
const size_t m = T.length();
size_t matches=0;
size_t comparisons =0;
//Setting up extended bad character rule
create_Rlist(P,Rlist);
//Setting up good suffix rule
vector<size_t> N(n,0);
reverseZ(N,P,comparisons);
vector<int> Lprime(n,0);
good_suffix(Lprime,N,n);
vector<int> lprime(n,0);
//largest suffix of P[i...n] that is also a prefix of P
sufpref(lprime,N,n);
int k = n-1;
while(k < m){
int i = n-1;
int h = k;
int goodsuf;
while(i>-1 && P[i]==toupper(T[h])){
--i;
--h;
++comparisons;
}
if(i==-1){
++matches;
k += n-lprime[1];
}else{
//Good suffix rule shift
if(Lprime[i] > 0){
goodsuf = n-Lprime[i]-1;
}else{
goodsuf = n-lprime[i]-1;
}
//Bad character rule
int badchar = i-lookupR(Rlist,i,toupper(T[h]));
k += max(1,max(goodsuf,badchar));
}
}
cout << "Number of matches is: " << matches << endl;
cout << "Number of comparisons was: " << comparisons << endl;
}
|
#if !defined(LINE)
#define LINE
#include "./Point.h"
template <typename T>
struct Line
{
Point<T> pStart;
Point<T> pEnd;
Line() {}
Line(T x1, T y1, T x2, T y2)
{
this->pStart = Point<T>(x1, y1);
this->pEnd = Point<T>(x2, y2);
}
Line(Point<T> p1, Point<T> p2)
{
this->pStart = p1;
this->pEnd = p2;
}
void setStartPoint(Point<T> p)
{
this->pStart = p;
}
void setStartPoint(T x, T y)
{
this->pStart.x = x;
this->pStart.y = y;
}
void setEndPoint(Point<T> p)
{
this->pEnd = p;
}
void setEndPoint(T x, T y)
{
this->pEnd.x = x;
this->pEnd.y = y;
}
double getSlope()
{
return (pEnd.y - pStart.y) / (pEnd.x - pStart.x);
}
T getStartX()
{
return pStart.x;
}
T getEndX()
{
return pEnd.x;
}
T getStartY()
{
return pStart.y;
}
T getEndY()
{
return pEnd.y;
}
T getXgivenY(T pY)
{
// x1 = x + (1/slope) * (y1-y)
return pStart.x + (1 / getSlope()) * (pY - pStart.y);
}
T getYgivenX(T pX)
{
// y1 = y + slope (x1-x)
return pStart.y + getSlope() * (pX - pStart.x);
}
Point<T> getIntersectOfLines(Line<T> pLine)
{
T num = (pStart.x * pEnd.y - pStart.y * pEnd.x) * (pLine.pStart.x - pLine.pEnd.x) - (pStart.x - pEnd.x) * (pLine.pStart.x * pLine.pEnd.y - pLine.pStart.y * pLine.pEnd.x);
T den = (pStart.x - pEnd.x) * (pLine.pStart.y - pLine.pEnd.y) - (pStart.y - pEnd.y) * (pLine.pStart.x - pLine.pEnd.x);
T x = num / den;
num = (pStart.x * pEnd.y - pStart.y * pEnd.x) * (pLine.pStart.y - pLine.pEnd.y) - (pStart.y - pEnd.y) * (pLine.pStart.x * pLine.pEnd.y - pLine.pStart.y * pLine.pEnd.x);
den = (pStart.x - pEnd.x) * (pLine.pStart.y - pLine.pEnd.y) - (pStart.y - pEnd.y) * (pLine.pStart.x - pLine.pEnd.x);
T y = num / den;
return Point<T>(x, y);
}
int getPositionOfPoint(Point<T> point)
{
return (pEnd.x - pStart.x) * (point.y - pStart.y) - (pEnd.y - pStart.y) * (point.x - pStart.x);
}
};
#endif // LINE
|
#include <bits/stdc++.h>
using namespace std;
int main()
{ int i=1,flag,j;
for(int k=1;k<=4;k++){
for(int p=0;p<k;p++){
flag = 1;
for (j = 2; j <= i / 2; ++j) {
if (i % j == 0) {
flag = 0;
break;
}
}
if(i==1)
cout<<" * ";
else if (flag == 1)
cout << " # ";
else
cout<<" * ";
i++;
}
cout<<endl;
}
return 0;
}
|
#pragma once
#include <string>
#include <list>
using namespace std;
/***************************
* 观察者基类
****************************/
struct Blog;
struct Observer {
Observer() {}
virtual ~Observer() {}
virtual void attach(Blog*) {}
virtual void remove(Blog*) {}
virtual void update(Blog*) {}
};
/***************************
* 博客基类
****************************/
struct Blog {
Blog() {}
virtual ~Blog() {}
void notify();
virtual void setStatus(string str);
virtual string getStatus();
void attach(Observer* m_Obe);
void remove(Observer* m_Obe);
protected:
string m_status; //博客状态
private:
list<Observer*> obers; //观察者集合,此处最好用set
};
/***************************
* 具体的博客
****************************/
struct BlogCSDN : public Blog {
BlogCSDN(string _name) :m_name(_name)
{}
~BlogCSDN() {}
void setStatus(string str);
string getStatus();
private:
string m_name; //博主名称
};
struct BlogSINA : public Blog {
BlogSINA(string _name) :m_name(_name)
{}
~BlogSINA() {}
void setStatus(string str);
string getStatus();
private:
string m_name; //博主名称
};
/***************************
* 具体的观察者
****************************/
struct ObserverBlog : public Observer {
ObserverBlog(string _name):m_name(_name){}
~ObserverBlog() {}
void update(Blog* blog);
void attach(Blog* blog);
void remove(Blog* blog);
private:
string m_name; // 观察者名称
list<Blog*> blogs; //博客集合
};
void observerTest(void);
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* Copyright (C) 1995-2011 Opera Software AS. All rights reserved.
*
* This file is part of the Opera web browser. It may not be distributed
* under any circumstances.
*/
#include "core/pch.h"
#include "adjunct/quick_toolkit/widgets/QuickGrid/UniformGridSizer.h"
#include "adjunct/quick_toolkit/widgets/QuickGrid/GridCell.h"
#include "adjunct/quick_toolkit/widgets/QuickGrid/GridCellContainer.h"
#include "adjunct/quick_toolkit/widgets/QuickGrid/GridCellIterator.h"
#include "adjunct/quick_toolkit/widgets/QuickGrid/GridLayouter.h"
UniformGridSizer::UniformGridSizer(GridCellContainer& grid)
: m_grid(grid)
, m_valid(false)
{
}
void UniformGridSizer::CalculateCellSizes()
{
op_memset(m_cell_width, 0, sizeof(m_cell_width));
op_memset(m_cell_height, 0, sizeof(m_cell_height));
m_cell_horizontal_margins = 0;
m_cell_vertical_margins = 0;
for (GridCellIterator it(m_grid); it; ++it)
{
m_cell_width[MINIMUM] = max(m_cell_width[MINIMUM], it->GetMinimumWidth());
m_cell_width[NOMINAL] = max(m_cell_width[NOMINAL], it->GetNominalWidth());
m_cell_width[PREFERRED] = max(m_cell_width[PREFERRED], it->GetPreferredWidth());
m_cell_height[MINIMUM] = max(m_cell_height[MINIMUM], it->GetMinimumHeight(m_cell_width[MINIMUM]));
m_cell_height[NOMINAL] = max(m_cell_height[NOMINAL], it->GetNominalHeight(m_cell_width[NOMINAL]));
m_cell_height[PREFERRED] = max(m_cell_height[PREFERRED], it->GetPreferredHeight(m_cell_width[NOMINAL]));
const WidgetSizes::Margins margins = it->GetMargins();
m_cell_horizontal_margins = max(max(m_cell_horizontal_margins, margins.left), margins.right);
m_cell_vertical_margins = max(max(m_cell_vertical_margins, margins.top), margins.bottom);
}
m_valid = true;
}
unsigned UniformGridSizer::GetGridWidth(SizeType type)
{
if (!m_valid)
CalculateCellSizes();
if (m_cell_width[type] > WidgetSizes::UseDefault)
return m_cell_width[type];
unsigned width = m_cell_width[type] * m_grid.GetColumnCount();
width += m_cell_horizontal_margins * max(0, int(m_grid.GetColumnCount()) - 1);
return width;
}
unsigned UniformGridSizer::GetGridHeight(SizeType type)
{
if (!m_valid)
CalculateCellSizes();
return CalculateGridHeight(m_cell_height[type]);
}
unsigned UniformGridSizer::GetGridHeight(SizeType type, unsigned grid_width, GridLayouter& layouter)
{
if (!m_valid)
CalculateCellSizes();
layouter.SetGridLayoutWidth(grid_width);
return CalculateGridHeight(CalculateCellHeight(type, layouter));
}
unsigned UniformGridSizer::CalculateGridHeight(unsigned cell_height)
{
OP_ASSERT(m_valid);
if (cell_height > WidgetSizes::UseDefault)
return cell_height;
unsigned height = cell_height * m_grid.GetRowCount();
height += m_cell_vertical_margins * max(0, int(m_grid.GetRowCount()) - 1);
return height;
}
unsigned UniformGridSizer::CalculateCellHeight(SizeType type, GridLayouter& layouter)
{
const unsigned row_count = m_grid.GetRowCount();
unsigned max_cell_height = 0;
for (unsigned col = 0; col < m_grid.GetColumnCount(); ++col)
{
const unsigned col_width = layouter.GetColumnWidth(col);
for (unsigned row = 0; row < row_count; ++row)
{
GridCell* cell = m_grid.GetCell(col, row);
unsigned cell_height = 0;
switch (type)
{
case MINIMUM: cell_height = cell->GetMinimumHeight(col_width); break;
case NOMINAL: cell_height = cell->GetNominalHeight(col_width); break;
case PREFERRED: cell_height = cell->GetPreferredHeight(col_width); break;
}
max_cell_height = max(max_cell_height, cell_height);
}
}
return max_cell_height;
}
WidgetSizes::Margins UniformGridSizer::GetGridMargins()
{
if (!m_valid)
CalculateCellSizes();
WidgetSizes::Margins margins;
margins.left = margins.right = m_cell_horizontal_margins;
margins.top = margins.bottom = m_cell_vertical_margins;
return margins;
}
OP_STATUS UniformGridSizer::SetColumnSizes(GridLayouter& layouter)
{
if (!m_valid)
CalculateCellSizes();
RETURN_IF_ERROR(layouter.SetColumnCount(m_grid.GetColumnCount()));
for (unsigned col = 0; col < m_grid.GetColumnCount(); ++col)
{
layouter.SetColumnSizes(col,
m_cell_width[MINIMUM], m_cell_width[PREFERRED],
col == m_grid.GetColumnCount() - 1 ? 0 : m_cell_horizontal_margins);
}
return OpStatus::OK;
}
OP_STATUS UniformGridSizer::SetRowSizes(GridLayouter& layouter)
{
if (!m_valid)
CalculateCellSizes();
RETURN_IF_ERROR(layouter.SetRowCount(m_grid.GetRowCount()));
for (unsigned row = 0; row < m_grid.GetRowCount(); ++row)
{
layouter.SetRowSizes(row,
CalculateCellHeight(MINIMUM, layouter), CalculateCellHeight(PREFERRED, layouter),
row == m_grid.GetRowCount() - 1 ? 0 : m_cell_vertical_margins);
}
return OpStatus::OK;
}
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
**
** Copyright (C) 1995-2003 Opera Software AS. All rights reserved.
**
** This file is part of the Opera web browser. It may not be distributed
** under any circumstances.
**
*/
#ifndef DECODERFACTORYGIF_H
#define DECODERFACTORYGIF_H
#include "modules/img/imagedecoderfactory.h"
#include "modules/img/image.h"
class DecoderFactoryGif : public ImageDecoderFactory
#ifndef ASYNC_IMAGE_DECODERS
, public ImageDecoderListener
#endif
{
public:
#if defined(INTERNAL_GIF_SUPPORT) || defined(ASYNC_IMAGE_DECODERS_EMULATION)
ImageDecoder* CreateImageDecoder(ImageDecoderListener* listener);
#endif // INTERNAL_GIF_SUPPORT
BOOL3 CheckSize(const UCHAR* data, INT32 len, INT32& width, INT32& height);
BOOL3 CheckType(const UCHAR* data, INT32 len);
#ifndef ASYNC_IMAGE_DECODERS
virtual void OnLineDecoded(void* data, INT32 line, INT32 lineHeight) {}
virtual BOOL OnInitMainFrame(INT32 width, INT32 height) { peekwidth = width; peekheight = height; return FALSE; }
virtual void OnNewFrame(const ImageFrameData& image_frame_data) {}
virtual void OnAnimationInfo(INT32 nrOfRepeats) {}
virtual void OnDecodingFinished() {}
#ifdef IMAGE_METADATA_SUPPORT
virtual void OnMetaData(ImageMetaData id, const char* data){}
#endif // IMAGE_METADATA_SUPPORT
#ifdef EMBEDDED_ICC_SUPPORT
virtual void OnICCProfileData(const UINT8* data, unsigned datalen){}
#endif // EMBEDDED_ICC_SUPPORT
private:
INT32 peekwidth, peekheight;
#endif
};
#endif // !DECODERFACTORYGIF_H
|
#include <iostream>
#include <list>
using namespace std;
/*
* Represents a Graph
* Assumption 1: All nodes can be eventually reached by the source node (so it's not a disconnected graph)
* Assumption 2: Directed or undirected graph
* @param: numVertices: Number of vertices (nodes) in the graph
* @param: *adj: A pointer to an array of lists (double LL) - so adj[2] will be the 3rd DLL in the array
*/
class Graph{
public:
int numVertices;
list<int> *adjList;
Graph(int numVertices); // Constructor
void addEdge(int v, int w); // Function to add an edge to graph
void BFS(int s); // prints BFS traversal from a given source 's'
};
Graph::Graph(int numVertices){
this->numVertices = numVertices;
// Declare a new list of DLLs
// So you initialize an array of list<int> type with size 'numVertices'
// So every vertex in the graph has its own DLL
// and each of their DLL (list) is basically the list of the vertices it's directly attached to
adjList = new list<int> [numVertices];
}
void Graph::addEdge(int v, int w){
adj[v].push_back(w); // add 'w' vertex to v's list
}
// 's' is the source vertex from which the BFS will run
void Graph::BFS(int s){
// mark all the vertices as not visited in the start
bool *visited = new bool [numVertices];
for(int i = 0; i < numVertices; i++)
visited[i] = false;
// Create a queue for BFS
// So we are using a list<int> instead of queue<int> here
// which is fine cos we can use a DLL as a queue as well
list<int> queue;
// Mark the current node as visited + enqueue it
// How to mark it visited? assign the corresponding value in the bool array as true
visited[s] = true;
queue.push_back(s);
// Declare an iterator
list<int>::iterator i;
// Run the loop as long as the queue is not empty
while(queue.empty() != true){
// Dequeue a vertex from queue and print it
s = queue.front();
cout << s << '\t';
queue.pop_front();
// Get all adjacent vertices of the dequeue vertex s
// If an adjacenet has not been visiter -> mark it visited + enqueue it
for(i = adj[s].begin(); i != adj[s].end(); i++){
if(visited[*i] != true){
visited[*i] = true;
queue.push_back(*i);
}
}
}
}
// Test Client
int main(){
// Create a graph
Graph g(4);
// Add edges
g.addEdge(0, 1);
g.addEdge(0, 2);
g.addEdge(1, 2);
g.addEdge(2, 0);
g.addEdge(2, 3);
g.addEdge(3, 3);
// Print the BFS traversal for vertex 2
g.BFS(2);
return 0;
}
|
// Copyright (c) 2021 Thomas Kaldahl
#ifndef FINLIN_HPP
#define FINLIN_HPP
#define CL_TARGET_OPENCL_VERSION 200
#include <CL/cl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
class FinLin {
friend class Vec;
friend class Mat;
friend class Veci;
friend class Mati;
static void setArg(cl_kernel kernel, int argno, cl_mem obj);
static void setArg(cl_kernel kernel, int argno, double obj);
static void setArg(cl_kernel kernel, int argno, int obj);
static void writeBuffer(
cl_mem buffer,
size_t offset,
size_t cb,
const void *ptr
);
static void execKernel(
cl_kernel kernel,
size_t offset,
size_t globalWorkSize,
size_t localWorkSize
);
static void execKernel(
cl_kernel kernel,
size_t offset,
size_t globalSizeX,
size_t globalSizeY,
size_t localWorkSize
);
static void readBuffer(
cl_mem buffer,
size_t offset,
size_t cb,
void *ptr
);
static const char *SRC; // Kernel source code
static int err; // Error code output
static cl_platform_id *platforms;
static cl_device_id *devices;
static cl_uint *platformCount;
static cl_uint *deviceCount;
static int platformID;
static int deviceID;
static cl_context context;
static cl_command_queue commandQueue;
static cl_program program;
// Kernels
static cl_kernel scale; // Scale an array
static cl_kernel add; // Add two arrays element-wise
static cl_kernel addScaled; // Add a scalar multiple of an array to another
static cl_kernel hadamard; // Multiply two arrays element-wise
static cl_kernel sigmoid; // Perform fast sigmoid on each element
static cl_kernel dsigmoid; // Perform derivative of sigmoid on each element
static cl_kernel reduce; // Halves an even-length array, preserving sum.
static cl_kernel matVec; // Matrix and vector multiplication
static cl_kernel matMul; // Matrix multiplication
static cl_kernel compNot; // Replace zeros with ones, non-zeros with zeros.
// Integer kernels
static cl_kernel scalei; // Scale an array
static cl_kernel dividei; // Divide an array by a scalar
static cl_kernel modulo; // Perform modulo on integer array
static cl_kernel addi; // Add two arrays element-wise
static cl_kernel addScaledi; // Add a scalar multiple of an array to another
static cl_kernel hadamardi; // Multiply two arrays element-wise
static cl_kernel reducei; // Halves an even-length array, preserving sum.
static cl_kernel matVeci; // Matrix and vector multiplication
static cl_kernel matMuli; // Matrix multiplication
static cl_kernel compNoti; // Replace zeros with ones, non-zeros with zeros.
static void checkErr(); // Stops the program if there is an error
static double *res; // Results from kernels
static cl_mem memRes; // Memory object for res
public:
static void init(int platform, int device); // Sets up all the OpenCL stuff.
// Must be called before
// creating any objects.
};
class Veci;
class Vec { // Vector, real components, double precision, on the GPU.
friend class Mat;
friend class Veci;
int d; // Dimension
double *data; // Components
cl_mem clmem; // OpenCL memory object
bool dirty; // Changes have been made in RAM but not in GPU RAM
void createMem();
public:
// Statics
static Vec randomUniform(int dim, double min, double max);
static Vec *gramSchmidt(int numVecs, Vec *vecs); // Mutates input.
// Constructors
Vec(int dimension); // Zero vector
Vec(int dimension, double* components);
Vec(int dimension, double value); // Populates all components with value
Vec(Veci vec); // Convert integers to doubles
// Accessors
int dim() const; // Dimension
double comp(int index) const; // Component
char *string() const; // As a string
// Unary operations
Vec operator-() const;
double norm() const; // Magnitude
Vec normal() const; // Unit vector
double sum() const; // Sum of components
Vec operator~() const; // Replace zeros with ones, non-zeros with zeros.
Vec sigmoid() const; // Fast sigmoid function
Vec dsigmoid() const; // Derivative of fast sigmoid function
// Binary operations
Vec operator*(double scalar) const;
Vec operator/(double divisor) const;
double operator^(double exponent) const; // Magnitude raised to power
Vec operator+(Vec addend) const; // Throws error if dimensions mis-match
Vec operator-(Vec subtrahend) const; // ''
Vec operator&(Vec multiplier) const; // Hadamard product
double operator*(Vec multiplier) const; // Dot product
// In-place operations
Vec operator*=(double scalar);
Vec operator/=(double divisor);
Vec operator+=(Vec addend);
Vec operator-=(Vec subtrahend);
Vec operator&=(Vec multiplier); // Hadamard product
Vec normalize();
Vec setSigmoid(); // Fast sigmoid function
Vec setDsigmoid(); // Derivative of fast sigmoid function
// Mutators
double setComp(int index, double value); // Sets component.
// Returns previous value.
// Technical methods
Vec copy() const;
bool update(); // If necessary, updates the GPU memory and returns true.
// Vector operations should do this automatically.
};
Vec operator*(double scalar, Vec vector);
class Mati;
class Mat { // Matrix, real components, double precision, on the GPU.
friend class Mati;
double *data; // Components, row by row
int h; // Height
int w; // Width
cl_mem clmem; // OpenCL memory object
bool dirty; // Changes have been made in RAM but not in GPU RAM
void createMem();
public:
// Statics
static Mat randomUniform(int height, int width, double min, double max);
static Mat fromRowVec(Vec row);
static Mat fromColVec(Vec col);
static Mat fromRowVecs(int numVecs, Vec *vecs); // Throws error if
static Mat fromColVecs(int numVecs, Vec *vecs); // dimensions don't match.
// Constructors
Mat(int size); // Identity matrix
Mat(int size, double scalar); // Scalar multiple of identity matrix
Mat(int height, int width); // Zero matrix
Mat(int height, int width, double *data);
Mat(Mati mat); // Convert integers to doubles
// Accessors
int height() const;
int width() const;
double comp(int r, int c) const; // Component
char *string() const; // As a string
// Unary operations
bool invertible() const;
double det() const; // Determinant
double trace() const;
Mat operator-() const;
Mat T() const; // Transpose
Mat inv() const; // Inverse. Throws error if not invertible.
Mat operator~() const; // Replace zeros with ones, non-zeros with zeros.
// Misc operations
Vec rowVec(int row) const;
Vec colVec(int col) const;
// Binary operations
Mat operator*(double scalar) const;
Mat operator/(double divisor) const;
Mat operator^(int exponent) const; // Exponentiation
Vec operator*(Vec multiplier); // Throws error if dimensions mis-match
Mat operator*(Mat multiplier); // ''
Mat operator&(Mat multiplier) const; // Hadamard product
Mat operator+(Mat addend) const;
Mat operator-(Mat subtrahend) const;
// In-place operations
Mat operator*=(double scalar);
Mat operator/=(double divisor);
Mat operator^=(int exponent); // Exponentiation
Mat operator&=(Mat multiplier); // Hadamard product
Mat operator+=(Mat addend);
Mat operator-=(Mat subtrahend);
Mat RREF();
// Mutators
double setComp(int r, int c, double value); // Sets component.
// Returns previous value.
// Technical methods
Mat copy() const;
bool update(); // If necessary, updates the GPU memory and returns true.
// Matrix operations should do this automatically.
};
Mat operator*(double scalar, Mat matrix);
class Veci { // Vector, integer components, on the GPU.
friend class Vec;
friend class Mati;
int d; // Dimension
int *data; // Components
cl_mem clmem; // OpenCL memory object
bool dirty; // Changes have been made in RAM but not in GPU RAM
void createMem();
public:
// Statics
static Veci randomUniform(int dim, int min, int max);
// Constructors
Veci(int dimension); // Zero vector
Veci(int dimension, int* components);
Veci(int dimension, int value); // Populates all components with value
Veci(Vec vec); // Round doubles down
// Accessors
int dim() const; // Dimension
int comp(int index) const; // Component
char *string() const; // As a string
// Unary operations
int sum() const; // Sum of components
Veci operator~() const; // Replace zeros with ones, non-zeros with zeros.
Veci operator-() const;
// Binary operations
Veci operator*(int scalar) const;
Veci operator/(int divisor) const; // Round down
Veci operator%(int modulus) const; // Modulo
int operator^(int exponent) const; // Magnitude raised to even power
Veci operator+(Veci addend) const; // Throws error if dimensions mis-match
Veci operator-(Veci subtrahend) const; // ''
Veci operator&(Veci multiplier) const; // Hadamard product
int operator*(Veci multiplier) const; // Dot product
// In-place operations
Veci operator*=(int scalar);
Veci operator/=(int divisor); // Round down
Veci operator%=(int modulus); // Modulo
Veci operator+=(Veci addend);
Veci operator-=(Veci subtrahend);
Veci operator&=(Veci multiplier); // Hadamard product
// Mutators
int setComp(int index, int value); // Sets component.
// Returns previous value.
// Technical methods
Veci copy() const;
bool update(); // If necessary, updates the GPU memory and returns true.
// Vecitor operations should do this automatically.
};
Veci operator*(int scalar, Veci vector);
class Mati { // Matrix, integer components, on the GPU.
int *data; // Components, row by row
int h; // Height
int w; // Width
cl_mem clmem; // OpenCL memory object
bool dirty; // Changes have been made in RAM but not in GPU RAM
void createMem();
public:
// Statics
static Mati randomUniform(int height, int width, int min, int max);
static Mati fromRowVec(Veci row);
static Mati fromColVec(Veci col);
static Mati fromRowVecs(int numVecs, Veci *vecs); // Throws error if
static Mati fromColVecs(int numVecs, Veci *vecs); // dimensions don't match.
// Constructors
Mati(int size); // Identity matrix
Mati(int height, int width); // Zero matrix
Mati(int height, int width, int *data);
Mati(Mat mat); // Round doubles down
// Accessors
int height() const;
int width() const;
int comp(int r, int c) const; // Component
char *string() const; // As a string
// Unary operations
int trace() const;
Mati operator-() const;
Mati T() const; // Transpose
Mati operator~() const; // Replace zeros with ones, non-zeros with zeros.
// Misc operations
Veci rowVeci(int row) const;
Veci colVeci(int col) const;
// Binary operations
Mati operator*(int scalar) const;
Mati operator/(int divisor) const; // Rounds down
Mati operator%(int modulus) const; // Modulo
Mati operator^(int exponent) const; // Exponentiation
Veci operator*(Veci multiplier); // Throws error if dimensions mis-match
Mati operator*(Mati multiplier); // ''
Mati operator&(Mati multiplier) const; // Hadamard product
Mati operator+(Mati addend) const;
Mati operator-(Mati subtrahend) const;
// In-place operations
Mati operator*=(int scalar);
Mati operator/=(int divisor); // Rounds down
Mati operator%=(int modulus); // Modulo
Mati operator^=(int exponent); // Exponentiation
Mati operator&=(Mati multiplier); // Hadamard product
Mati operator+=(Mati addend);
Mati operator-=(Mati subtrahend);
// Mutators
int setComp(int r, int c, int value); // Sets component.
// Returns previous value.
// Technical methods
Mati copy() const;
bool update(); // If necessary, updates the GPU memory and returns true.
// Matirix operations should do this automatically.
};
Mati operator*(int scalar, Mati matrix);
#endif
|
// This project controlls 6 MOSFETS that PWM two RGB light strips.
// - One knob controls decay of all channels
// - Six CV inputs
// - Six CV outputs
//Using an Arduino Micro
//Input and Output Pin Definitions
int pin_input_decay = A0; // 0-5V, if inputting from 12V eurorack, make sure to scale it to 5V 25mA max
int pin_input_cv1 = A1; // A-Red
int pin_input_cv2 = A2; // A-Green
int pin_input_cv3 = A3; // A-Blue
int pin_input_cv4 = A4; // B-Red
int pin_input_cv5 = A5; // B-Blue
int pin_input_cv6 = A6; // B-Green
int pin_output_pwm1 = 3; //PWM Only on these pins on the Micro: 3, 5, 6, 9, 10, 11 and 13
int pin_output_pwm2 = 4;
int pin_output_pwm3 = 6;
int pin_output_pwm4 = 9;
int pin_output_pwm5 = 10;
int pin_output_pwm6 = 11;
//Internal variables
int cv1_raw = 0;
int cv2_raw = 0;
int cv3_raw = 0;
int cv4_raw = 0;
int cv5_raw = 0;
int cv6_raw = 0;
float cv1_with_decay = 0;
float cv2_with_decay = 0;
float cv3_with_decay = 0;
float cv4_with_decay = 0;
float cv5_with_decay = 0;
float cv6_with_decay = 0;
int decay_raw = 0;
float decay_per_loop = 0;
//Settings
float decay_max = 1;
float decay_min = 0.001;
void setup() {
pinMode(pin_input_decay, INPUT);
pinMode(pin_input_cv1, INPUT);
pinMode(pin_input_cv2, INPUT);
pinMode(pin_input_cv3, INPUT);
pinMode(pin_input_cv4, INPUT);
pinMode(pin_input_cv5, INPUT);
pinMode(pin_input_cv6, INPUT);
pinMode(pin_output_pwm1, OUTPUT);
pinMode(pin_output_pwm2, OUTPUT);
pinMode(pin_output_pwm3, OUTPUT);
pinMode(pin_output_pwm4, OUTPUT);
pinMode(pin_output_pwm5, OUTPUT);
pinMode(pin_output_pwm6, OUTPUT);
analogWrite(pin_output_pwm1, 0);
analogWrite(pin_output_pwm2, 0);
analogWrite(pin_output_pwm3, 0);
analogWrite(pin_output_pwm4, 0);
analogWrite(pin_output_pwm5, 0);
analogWrite(pin_output_pwm6, 0);
}
void loop() {
readInputs();
writeOutputs();
}
void readInputs() {
//Read pin values
decay_raw = analogRead(pin_input_decay); //0-1023
cv1_raw = analogRead(pin_input_cv1);
cv2_raw = analogRead(pin_input_cv2);
cv3_raw = analogRead(pin_input_cv3);
cv4_raw = analogRead(pin_input_cv4);
cv5_raw = analogRead(pin_input_cv5);
cv6_raw = analogRead(pin_input_cv6);
//Update Decay
decay_per_loop = mapFloat(decay_raw, 0, 1023, decay_min, decay_max);
//Update each CV (better ways to write this, but this is easy and the speed doesn't matter)
if(cv1_raw > cv1_with_decay) {cv1_with_decay = cv1_raw;} else {cv1_with_decay -= decay_per_loop;}
if(cv2_raw > cv2_with_decay) {cv2_with_decay = cv2_raw;} else {cv2_with_decay -= decay_per_loop;}
if(cv3_raw > cv3_with_decay) {cv3_with_decay = cv3_raw;} else {cv3_with_decay -= decay_per_loop;}
if(cv4_raw > cv4_with_decay) {cv4_with_decay = cv4_raw;} else {cv4_with_decay -= decay_per_loop;}
if(cv5_raw > cv5_with_decay) {cv5_with_decay = cv5_raw;} else {cv5_with_decay -= decay_per_loop;}
if(cv6_raw > cv6_with_decay) {cv6_with_decay = cv6_raw;} else {cv6_with_decay -= decay_per_loop;}
}
void writeOutputs() {
analogWrite(pin_output_pwm1, (int)(cv1_with_decay/4.0)); //output is 0-255, so divide by four
analogWrite(pin_output_pwm2, (int)(cv2_with_decay/4.0));
analogWrite(pin_output_pwm3, (int)(cv3_with_decay/4.0));
analogWrite(pin_output_pwm4, (int)(cv4_with_decay/4.0));
analogWrite(pin_output_pwm5, (int)(cv5_with_decay/4.0));
analogWrite(pin_output_pwm6, (int)(cv6_with_decay/4.0));
}
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
|
// Created on: 2006-05-28
// Created by: Alexander GRIGORIEV
// Copyright (c) 2006-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef VrmlData_Color_HeaderFile
#define VrmlData_Color_HeaderFile
#include <VrmlData_ArrayVec3d.hxx>
#include <Quantity_Color.hxx>
#include <gp_XYZ.hxx>
/**
* Implementation of the node Color
*/
class VrmlData_Color : public VrmlData_ArrayVec3d
{
public:
// ---------- PUBLIC METHODS ----------
/**
* Empty constructor.
*/
inline VrmlData_Color () {}
/**
* Constructor.
*/
inline VrmlData_Color (const VrmlData_Scene& theScene,
const char * theName,
const size_t nColors =0,
const gp_XYZ * arrColors=0L)
: VrmlData_ArrayVec3d (theScene, theName, nColors, arrColors)
{}
/**
* Query one color
* @param i
* index in the array of colors [0 .. N-1]
* @return
* the color value for the index. If index irrelevant, returns (0., 0., 0.)
*/
inline const Quantity_Color Color (const Standard_Integer i) const
{ return Quantity_Color (Value(i).X(), Value(i).Y(), Value(i).Z(),
Quantity_TOC_sRGB); }
/**
* Set the array data
*/
inline void SetColors (const size_t nColors,
const gp_XYZ * arrColors)
{ myLength = nColors; myArray = arrColors; }
/**
* Create a copy of this node.
* If the parameter is null, a new copied node is created. Otherwise new node
* is not created, but rather the given one is modified.<p>
*/
Standard_EXPORT virtual Handle(VrmlData_Node)
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
/**
* Read the Node from input stream.
*/
Standard_EXPORT virtual VrmlData_ErrorStatus
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
/**
* Write the Node to the Scene output.
*/
Standard_EXPORT virtual VrmlData_ErrorStatus
Write (const char * thePrefix) const Standard_OVERRIDE;
private:
// ---------- PRIVATE FIELDS ----------
public:
// Declaration of CASCADE RTTI
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Color,VrmlData_ArrayVec3d)
};
// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE (VrmlData_Color, VrmlData_ArrayVec3d)
#endif
|
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2012-2013.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef _GDCMIO_DICOMSRWRITERMANAGER_HPP_
#define _GDCMIO_DICOMSRWRITERMANAGER_HPP_
#include <fwData/Image.hpp>
#include "gdcmIO/writer/DicomModuleWriter.hxx"
namespace gdcmIO
{
namespace writer
{
/**
* @brief This class handles SR content to save.
*
* It will call SR writer.
*
* @class DicomSRWriterManager
* @author IRCAD (Research and Development Team).
* @date 2011.
*/
class GDCMIO_CLASS_API DicomSRWriterManager : public DicomModuleWriter< ::fwData::Image >
{
public :
GDCMIO_API DicomSRWriterManager();
GDCMIO_API ~DicomSRWriterManager();
/**
* @brief Load and start appropriate SR writing tools.
*
* This is one of last managers of the writing chain. The loaded tools will
* write one file.
*
* @note Currently, it just writes one SR document.
*
* @param a_gDs Root of a data set for a DICOM file.
* @param a_path Folder path where SR document will be saved.
*/
GDCMIO_API void write(::gdcm::DataSet & a_gDs, const ::boost::filesystem::path & a_path);
};
} // namespace writer
} // namespace gdcmIO
#endif // _GDCMIO_DICOMSRWRITERMANAGER_HPP_
|
#ifndef WGF_CONFIGFILE_H
#define WGF_CONFIGFILE_H
#include <map>
#include <string>
namespace WGF
{
/** \brief A configuration file containing infos as key = value
Optionally with comments in C-style. NOT ";"! Values can be strings, integers or floats.
\note use lower-case on keys as those from the config file will be stored as lower case anyway **/
class Configfile
{
public:
/** Default constructor */
Configfile();
/** Default destructor */
virtual ~Configfile();
/** Load the values from a file
\return success **/
bool LoadFromFile(const std::string& filename);
/** Parse one line to get key & value if possible
\note can be parsed if there is at least one = but that doesn't guarantee it will make sense! **/
void ParseLine(const std::string& line);
/** Save the values to a file
\return success **/
bool SaveToFile(const std::string& filename);
/** set a key to a string value
\note removes values of other type with same key**/
void SetString(const std::string& key, const std::string& value);
/** set a key to an integer value
\note removes values of other type with same key**/
void SetInt(const std::string& key, int value);
/** set a key to a float value
\note removes values of other type with same key**/
void SetFloat(const std::string& key, float value);
/** gets a string value for a given key
\note Logs to Framework-Logfile if the value does not exist.
\note Automatically converts floats and ints.
\return value or defaultvalue if it does not exist **/
const std::string GetString(const std::string& key, const std::string& defaultvalue = "");
/** gets an int value for a given key
\note Logs to Framework-Logfile if the value does not exist or is of wrong type.
\note Float is automatically converted to int
\return value or defaultvalue if it does not exist **/
const int GetInt(const std::string& key, int defaultvalue = -1);
/** gets a float value for a given key
\note Logs to Framework-Logfile if the value does not exist or is of wrong type.
\note Int is automatically converted to float
\return value or defaultvalue if it does not exist **/
const float GetFloat(const std::string& key, float defaultvalue = -1.0);
protected:
/** All the strings saved **/
std::map<std::string, std::string> mStrings;
/** All the integers saved **/
std::map<std::string, int> mInts;
/** All the floats saved **/
std::map<std::string, float> mFloats;
};
} // namespace WGF
#endif // WGF_CONFIGFILE_H
|
class Solution {
public:
vector<int> productExceptSelf(vector<int>& nums) {
if(nums.size() < 2) return {};
vector<int> res(nums.size());
res[0] = nums[0];
for(int i=1; i<nums.size(); ++i){
res[i] = res[i-1]*nums[i];
}
int temp = 1;
for(int i=nums.size()-1; i>0; --i){
res[i] = res[i-1]*temp;
temp*=nums[i];
}
res[0] = temp;
return res;
}
};
|
/* Problem: https://www.codechef.com/CDTR1502/problems/MULTIPLY/ */
#include <bits/stdc++.h>
using namespace std;
// A[] represents coefficients of first polynomial
// B[] represents coefficients of second polynomial
// m and n are sizes of A[] and B[] respectively
int *multiply(int A[], int B[], int m, int n)
{
int *prod = new int[m+n-1];
// Initialize the porduct polynomial
for (int i = 0; i<m+n-1; i++)
prod[i] = 0;
// Multiply two polynomials term by term
// Take ever term of first polynomial
for (int i=0; i<m; i++)
{
// Multiply the current term of first polynomial
// with every term of second polynomial.
for (int j=0; j<n; j++)
prod[i+j] += A[i]*B[j];
}
return prod;
}
// A utility function to print a polynomial
void printPoly(int poly[], int n)
{
for (int i=0; i<n; i++)
{
cout << poly[i];
if (i != 0)
cout << "x^" << i ;
if (i != n-1)
cout << " + ";
}
}
int main() {
int firstT;
int secondT;
cin >> firstT >> secondT;
int k1 = firstT;
int k2 = secondT;
vector<int> vec;
int temp;
while(firstT--) {
cin >> temp;
vec.push_back(temp);
}
int A[k1];
for(int i=0; i<vec.size();i++)
A[i] = vec[i];
vec.clear();
while(secondT--) {
cin >> temp;
vec.push_back(temp);
}
int B[k2];
for(int i=0; i<vec.size();i++)
B[i] = vec[i];
int m = sizeof(A)/sizeof(A[0]);
int n = sizeof(B)/sizeof(B[0]);
int *prod = multiply(A, B, m, n);
printPoly(prod, m+n-1);
return 0;
}
|
/*
ID: stevenh6
TASK: fence9
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FOR0(i, a) FOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define RFOR0(i, a) ROF(i, 0, a)
ofstream fout;
ifstream fin;
void setIO(string t)
{
fout.open(t + ".out");
fin.open(t + ".in");
}
// End of template
int n, m, p;
int gcd(int x, int y)
{
if (x == 0)
{
return y;
}
while (y != 0)
{
int t = y;
y = x % y;
x = t;
}
return x;
}
int main()
{
setIO("fence9");
fin >> n >> m >> p;
int sol = (p * m - gcd(n, m) - gcd(abs(n - p), m) - p) / 2 + 1;
fout << sol << endl;
}
|
//defines e includes
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep(i, a, n) for(i=int(a);i<int(n);i++)
#define rep2(i, a, n, jump) for(i=int(a);i<int(n);i+=int(jump))
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define mp make_pair
#define MAX 10010
#define oo INT_MAX
using namespace std;
//tipagem de pares
typedef pair<int, int> ii;
typedef pair<char, char> cc;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
//tipagem de vetores
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<bool> vb;
//tipagem de outras estruturas
typedef queue<int> qi;
typedef deque<int> dqi;
//tipagem de tipos primitivos
typedef long long int ll;
typedef unsigned long long int ull;
int main()
{
fastio;
int n;
while(cin >> n && n){
int q = 0;
while(n--){
int ci, vi;
cin >> ci >> vi;
if(vi >= 2){
q += vi/2;
}
}
cout << q/2 << '\n';
}
cout << '\n';
return 0;
}
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* Copyright (C) 1995-2011 Opera Software AS. All rights reserved.
*
* This file is part of the Opera web browser. It may not be distributed
* under any circumstances.
*/
#ifndef SYNC_OLD_PASSWORD_MISSING_DIALOG_H
#define SYNC_OLD_PASSWORD_MISSING_DIALOG_H
#include "adjunct/quick_toolkit/widgets/Dialog.h"
#include "adjunct/quick/dialogs/SimpleDialog.h"
#include "modules/hardcore/mh/mh.h"
class SyncManager;
class SyncOldPasswordMissingDialog : public Dialog
{
class AreYouSureDialog : public SimpleDialog
{
SyncOldPasswordMissingDialog* m_parent;
public:
AreYouSureDialog(SyncOldPasswordMissingDialog* parent): m_parent(parent) {}
OP_STATUS Init();
UINT32 OnOk();
};
public:
SyncOldPasswordMissingDialog(SyncManager & sync_manager);
~SyncOldPasswordMissingDialog();
/**
* @see MessageObject
*/
virtual void HandleCallback(OpMessage msg, MH_PARAM_1 par1, MH_PARAM_2 par2);
/**
* @see OpInputContext
*/
virtual Type GetType() { return DIALOG_TYPE_SYNC_OLD_PASSWORD_MISSING; }
virtual BOOL OnInputAction(OpInputAction* action);
/**
* @see Dialog
*/
virtual void OnInit();
virtual DialogType GetDialogType() { return TYPE_OK_CANCEL; }
virtual DialogImage GetDialogImageByEnum() { return IMAGE_WARNING; }
virtual const char* GetHelpAnchor() {return "link.html";}
virtual void OnChange(OpWidget *widget, BOOL changed_by_mouse);
/**
* @see DesktopWindow
*/
virtual const char* GetWindowName() { return "Sync Old Password Missing Dialog"; }
private:
void OkClicked();
void ShowError();
void HideError();
void ShowProgressInfo(Str::LocaleString info_id);
void HideProgressInfo();
void SetInProgress(BOOL in_progress);
SyncManager& m_sync_manager;
BOOL m_in_progress;
};
#endif // SYNC_OLD_PASSWORD_MISSING_DIALOG_H
|
class FindFirstNode {
public:
struct MyFunctor {
bool operator ()(const ListNode& lhs, const ListNode& rhs) const {
return lhs.val < rhs.val;
}
};
ListNode* EntryNodeOfLoop(ListNode* pHead)
{
map<ListNode, int, MyFunctor> mm{};
ListNode* p = pHead;
while (p != nullptr) {
if (mm.count(*p)) {
return p;
}
mm[*p] = 1;
p = p->next;
}
return nullptr;
}
void test() {
ListNode* h = new ListNode(1);
h->next = new ListNode(3);
ListNode* h2 = new ListNode(4);
h->next->next = h2;
h2->next = new ListNode(77);
h2->next->next = new ListNode(55);
h2->next->next->next = h2;
cout << h << endl;
cout << EntryNodeOfLoop(h) << endl;
}
};
|
// 0921_3.cpp : 定义控制台应用程序的入口点。
//多项式求和
//多项式的描述如下:
//1 - 1 / 2 + 1 / 3 - 1 / 4 + 1 / 5 - 1 / 6 + ...
//现在请你求出该多项式的前n项的和。
#include <iostream>
#include<cstdio>
using namespace std;
double function(int x)
{
double sum=0;
for (int i = 1; i <= x; i++)
{
sum = sum + pow(-1, i + 1)*(1.0 / i);
}
return sum;
}
int main()
{
int m;
const int size = 100;
while (cin >> m)
{
int i;
int a[size];
if (m >= 100)
break;
for (i = 0; i < m; i++)
{
cin >> a[i];
if (a[i] >= 1000)
break;
}
double sum[size];
for (i = 0; i < m; i++)
sum[i] = 0;
for (i = 0; i < m; i++)
{
sum[i] = function(a[i]);
printf("%.2f\n", sum[i]);
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main(){
long long int n,res=1;
cin>>n;
if(n>=6){
cout<<9;
}
else{
while(n>0){
res*=n;
n--;
}
while(res>9){
int temp=0;
while(res){
temp+=res%10;
res/=10;
}
res=temp;
}
cout<<res;
}
}
|
//Automobile.cpp
#include "Automobile.h"
#include "Park.h"
#include <string>
using namespace std;
Automobile::Automobile(string name, int payment) : name(name), payment(payment) { ; }
void Automobile::enter(Park *park)
{
park->assignAutomobile(this);
}
void Automobile::leave(Park *park)
{
park->passAutomobile(this, payment);
}
string Automobile::getName()
{
return name;
}
|
//
// ColaPrioridades.h
// Cola
//
// Created by Daniel on 13/10/14.
// Copyright (c) 2014 Gotomo. All rights reserved.
//
#ifndef __Cola__ColaPrioridades__
#define __Cola__ColaPrioridades__
#include <iostream>
#include "Cola.h"
template <class T>
class ColaPrioridades : protected Cola<T>{
};
#endif /* defined(__Cola__ColaPrioridades__) */
|
#pragma once
// The reference implementation for the code is within this documentation: http://www.faqs.org/rfcs/rfc1952.html
// The reference implementation was turned into a recursive function
/**
* To use: create a string id from a string (without quotes) at compile time with SID(string)
* Using StrID GetStrID( const char* string ) will use the same method as SID, except it will
* Store the id in a map so the string can be looked up with const char* GetStringFromStrID( StrID id )
*
*/
#define STORE_IDS 1
// Documentation Copyright:
/*
Copyright (c) 1996 L. Peter Deutsch
Permission is granted to copy and distribute this document for any
purpose and without charge, including translations into other
languages and incorporation into compilations, provided that the
copyright notice and this notice are preserved, and that any
substantive changes or deletions from the original are clearly
marked.
A pointer to the latest version of this and related documentation in
HTML format can be found at the URL
<ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html>.
*/
#include <cstring>
#include <cstdint>
#include <iostream>
#define DEBUG_USE_STRING_AS_STRID
#ifdef DEBUG_USE_STRING_AS_STRID
typedef std::string StrID;
#else
typedef unsigned int StrID; /* Added By Brandon Svochak*/
#endif
// Generate CRC lookup table
template <unsigned c, int k = 8>
struct f : f<((c & 1) ? 0xedb88320 : 0) ^ (c >> 1), k - 1> {};
template <unsigned c> struct f<c, 0> { enum { value = c }; };
#define CRC32_A(x) CRC32_B(x) CRC32_B(x + 128)
#define CRC32_B(x) CRC32_C(x) CRC32_C(x + 64)
#define CRC32_C(x) CRC32_D(x) CRC32_D(x + 32)
#define CRC32_D(x) CRC32_E(x) CRC32_E(x + 16)
#define CRC32_E(x) CRC32_F(x) CRC32_F(x + 8)
#define CRC32_F(x) CRC32_G(x) CRC32_G(x + 4)
#define CRC32_G(x) CRC32_H(x) CRC32_H(x + 2)
#define CRC32_H(x) CRC32_I(x) CRC32_I(x + 1)
#define CRC32_I(x) f<x>::value ,
/* Code below was modified and added by Brandon Svochak */
constexpr unsigned crc_table[] = { CRC32_A( 0 ) };
// Constexpr implementation and helpers
constexpr unsigned int crc32_impl( const unsigned char* p, size_t len, unsigned int crc ) {
return len ?
crc32_impl( p + 1, len - 1, (crc >> 8) ^ crc_table[(crc & 0xFF) ^ *p] )
: crc;
}
constexpr unsigned int crc32( const uint8_t* data, size_t length ) {
return ~crc32_impl( data, length, ~0 );
}
constexpr size_t strlen_c( const char* str ) {
return *str ? 1 + strlen_c( str + 1 ) : 0;
}
#ifdef DEBUG_USE_STRING_AS_STRID
#define WSID(str) StrID(str)
#else
constexpr StrID WSID( const char* str ) {
return (StrID)crc32( (unsigned char*)str, strlen_c( str ) );
}
#endif
namespace Hourglass
{
namespace StrIDUtil
{
StrID GetStrID(const char* string);
const char* GetStringFromStrID(StrID id);
}
}
#if STORE_IDS
#define SID(string) Hourglass::StrIDUtil::GetStrID( #string )
#else
#define SID(string) WSID(#string)
#endif
|
/*
* Copyright 2016 Freeman Zhang <zhanggyb@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SKLAND_WAYLAND_XDG_POSITIONER_HPP_
#define SKLAND_WAYLAND_XDG_POSITIONER_HPP_
#include "xdg-shell.hpp"
namespace skland {
namespace wayland {
class XdgPopup;
struct XdgPositionerMeta;
class XdgPositioner {
friend class XdgPopup;
XdgPositioner(const XdgPositioner &) = delete;
XdgPositioner &operator=(const XdgPositioner &) = delete;
public:
enum AnchorType {
/**
* the center of the anchor rectangle
*/
kAnchorNone = 0, // ZXDG_POSITIONER_V6_ANCHOR_NONE = 0
/**
* the top edge of the anchor rectangle
*/
kAnchorTop = 1, // ZXDG_POSITIONER_V6_ANCHOR_TOP = 1,
/**
* the bottom edge of the anchor rectangle
*/
kAnchorBottom = 2, // ZXDG_POSITIONER_V6_ANCHOR_BOTTOM = 2,
/**
* the left edge of the anchor rectangle
*/
kAnchorLeft = 4, // ZXDG_POSITIONER_V6_ANCHOR_LEFT = 4,
/**
* the right edge of the anchor rectangle
*/
kAnchorRight = 8 // ZXDG_POSITIONER_V6_ANCHOR_RIGHT = 8,
};
enum GravityType {
/**
* center over the anchor edge
*/
kGravityNone = 0, // ZXDG_POSITIONER_V6_GRAVITY_NONE = 0,
/**
* position above the anchor edge
*/
kGravityTop = 1, // ZXDG_POSITIONER_V6_GRAVITY_TOP = 1,
/**
* position below the anchor edge
*/
kGravityBottom = 2, // ZXDG_POSITIONER_V6_GRAVITY_BOTTOM = 2,
/**
* position to the left of the anchor edge
*/
kGravityLeft = 4, // ZXDG_POSITIONER_V6_GRAVITY_LEFT = 4,
/**
* position to the right of the anchor edge
*/
kGravityRight = 8, // ZXDG_POSITIONER_V6_GRAVITY_RIGHT = 8,
};
enum ConstraintAdjustmentType {
kConstraintAdjustmentNone = 0, // ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE = 0,
kConstraintAdjustmentSlideX = 1, // ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1,
kConstraintAdjustmentSlideY = 2, // ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2,
kConstraintAdjustmentFlipX = 4, // ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X = 4,
kConstraintAdjustmentFlipY = 8, // ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8,
kConstraintAdjustmentResizeX = 16, //ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16,
kConstraintAdjustmentResizeY = 32 // ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
};
XdgPositioner();
~XdgPositioner();
void Setup(const XdgShell &xdg_shell);
void Destroy();
void SetSize(int width, int height);
void SetAnchorRect(int32_t x, int32_t y, int32_t width, int32_t height);
void SetAnchor(uint32_t anchor);
void SetGravity(uint32_t gravity);
void SetConstraintAdjustment(uint32_t constraint_adjustment);
void SetOffset(int32_t x, int32_t y);
void SetUserData(void *user_data);
void *GetUserData() const;
uint32_t GetVersion() const;
bool IsValid() const;
private:
std::unique_ptr<XdgPositionerMeta> metadata_;
};
} // namespace wayland
} // namespace skland
#endif // SKLAND_WAYLAND_XDG_POSITIONER_HPP_
|
#ifndef SDUZH_OWNLIB_NET_EPOLL_POLLER_H
#define SDUZH_OWNLIB_NET_EPOLL_POLLER_H
#include <unordered_map>
#include <sys/epoll.h>
#include <reactor/net/Poller.h>
namespace reactor {
namespace net {
class EPollPoller: public Poller {
public:
/// see epoll_create(2)
EPollPoller(int size);
~EPollPoller();
void update_channel(Channel *channel) override;
void remove_channel(Channel *channel) override;
int poll(ChannelList *active_channels, int timeout_ms=-1) override;
private:
uint32_t to_epoll_events(int events);
typedef std::unordered_map<int, Channel*> ChannelMap;
int epfd_;
ChannelMap channels_;
};
} // namespace net
} // namespace reactor
#endif
|
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <functional>
#include <numeric>
#include <sstream>
#include <complex>
typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
#define PI 3.1415926535897932384626433832795
#define sqr(x) ((x)*(x))
using namespace std;
#define M 1000000007
LL powm(LL x, LL y, LL m) {
LL res = 1;
while (y) {
if (y & 1)
res = (res * x) % m;
x = (x * x) % m;
y >>= 1;
}
return res;
}
int C[1010][1010];
int main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
for (int i = 0; i <= 1000; ++i) {
C[i][0] = 1;
for (int j = 1; j <= i; ++j) {
C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % M;
}
}
int T;
cin >> T;
while (T--) {
LL n, d;
cin >> n >> d;
LL ans = 0;
for (int i = 0; i <= n; ++i) {
int p1 = (powm(d + 1, n - i, M - 1) * powm(d, i, M - 1)) % (M - 1);
int p2 = (powm(d, n - i, M - 1) * powm(d - 1, i, M - 1)) % (M - 1);
if (i & 1) {
ans = (ans - C[n][i] * powm(2, p1, M) + M) % M;
ans = (ans + C[n][i] * powm(2, p2, M) + M) % M;
} else {
ans = (ans + C[n][i] * powm(2, p1, M) + M) % M;
ans = (ans - C[n][i] * powm(2, p2, M) + M) % M;
}
}
cout << ans << endl;
}
return 0;
}
|
/*
This file is part of SMonitor.
Copyright 2015~2016 by: rayx email rayx.cn@gmail.com
SMonitor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SMonitor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
#include "CStatisticsWidget.h"
#include "databasemanager.h"
#include "Define.h"
#include "excelhelper.h"
#include "CNoFocusDelegate.h"
#include <QTableWidgetItem>
#include <QDebug>
#include <QMessageBox>
#include <QFileDialog>
CStatisticsWidget::CStatisticsWidget(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
initWidget();
tableWidget->setColumnWidth(0, 200);
tableWidget->setColumnWidth(1, 200);
tableWidget->setColumnWidth(2, 200);
tableWidget->setColumnWidth(3, 200);
tableWidget->setColumnWidth(4, 200);
tableWidget->setColumnWidth(5, 100);
tableWidget->setItemDelegate(new CNoFocusDelegate(this));
connect(btn_ExportAll, &QPushButton::clicked, this, &CStatisticsWidget::exportAll);
}
CStatisticsWidget::~CStatisticsWidget()
{
}
void CStatisticsWidget::initWidget()
{
SoftwareinfoVector vec;
DatabaseManager::Instance()->ReadAllSoftwareInfo(vec);
int index = 0;
for (int i = 0; i < vec.count(); i++)
{
const SoftwareInfo& info = vec.at(i);
if(info.category == QString::fromLocal8Bit("网页"))
continue;
tableWidget->setRowCount(index + 1);
for (int j = 0; j < 6; j++)
{
SetItem(index, j, info);
}
index++;
}
for (int row = 0; row < tableWidget->rowCount(); row++)
{
QString name = tableWidget->item(row, 0)->text();
QString version = tableWidget->item(row, 1)->text();
m_dataRowHash.insert(name, row);
}
}
void CStatisticsWidget::SetItem(int row, int column, const SoftwareInfo& info)
{
QTableWidgetItem* item = new QTableWidgetItem;
item->setTextAlignment(Qt::AlignCenter);
switch(column)
{
case 0:
{
item->setText(info.name);
tableWidget->setItem(row, column, item);
}
break;
case 1:
{
item->setText(info.version);
tableWidget->setItem(row, column, item);
}
break;
case 2:
{
item->setText(QString::number(info.installNum));
tableWidget->setItem(row, column, item);
}
break;
case 3:
{
item->setText(QString::number(info.uninstalledNum));
tableWidget->setItem(row, column, item);
}
break;
case 4:
{
item->setText(info.category);
tableWidget->setItem(row, column, item);
}
break;
case 5:
{
QPushButton* btn_export = new QPushButton(QString::fromLocal8Bit("导出"),tableWidget);
btn_export->setMinimumWidth(50);
connect(btn_export, &QPushButton::clicked, this, &CStatisticsWidget::exportData);
tableWidget->setCellWidget(row, column, btn_export);
m_exportBtnHash.insert(btn_export, row);
}
break;
default:
break;
}
}
void CStatisticsWidget::exportData()
{
QPushButton* button = qobject_cast<QPushButton*> (sender());
if(button && m_exportBtnHash.contains(button))
{
int row = m_exportBtnHash.value(button);
qDebug() << row;
QString path = QFileDialog::getSaveFileName(this, QString::fromLocal8Bit("导出"),
QApplication::applicationDirPath(), tr("Excel (*.xml)"));
if(!path.isEmpty())
{
QString columnNames[6];
int columnWidths[6];
QStringList content, contentList;
for(int i = 0; i < tableWidget->columnCount() - 1; i++)
{
columnNames[i] = tableWidget->horizontalHeaderItem(i)->text();
columnWidths[i] = tableWidget->columnWidth(i);
content.append(tableWidget->item(row, i)->text());
}
contentList.append(content.join(";"));
bool bExport = ExcelHelper::Instance()->ToExcel(path, QString::fromLocal8Bit("软件安装信息统计"),
QString::fromLocal8Bit("软件安装信息统计"), columnNames, columnWidths, 5, contentList);
if(bExport)
{
QMessageBox::information(this, QString::fromLocal8Bit("信息"),
QString::fromLocal8Bit("导出信息成功"),
QString::fromLocal8Bit("确定"));
}
}
}
}
void CStatisticsWidget::updateInstallData(QPair<QString, QString> key, int num)
{
if(m_dataRowHash.contains(key.first))
{
int row = m_dataRowHash.value(key.first);
if(tableWidget->item(row, 1) && key.second == tableWidget->item(row, 1)->text())
tableWidget->item(row, 2)->setText(QString::number(num));
}
}
void CStatisticsWidget::updateUnInstallData(QPair<QString, QString> key, int num)
{
if(m_dataRowHash.contains(key.first))
{
int row = m_dataRowHash.value(key.first);
if(tableWidget->item(row, 1) && key.second == tableWidget->item(row, 1)->text())
tableWidget->item(row, 3)->setText(QString::number(num));
}
}
void CStatisticsWidget::updateAllNumData(const QString& name, const QString& version, int installNum, int unInstallNum)
{
if(m_dataRowHash.contains(name))
{
int row = m_dataRowHash.value(name);
if(tableWidget->item(row, 1) && version == tableWidget->item(row, 1)->text())
{
tableWidget->item(row, 2)->setText(QString::number(installNum));
tableWidget->item(row, 3)->setText(QString::number(unInstallNum));
}
}
}
void CStatisticsWidget::initData()
{
updateData();
}
void CStatisticsWidget::updateData()
{
for(int i = 0; i < tableWidget->rowCount(); i++){
tableWidget->removeCellWidget(i, 5);
tableWidget->removeRow(i);
}
QHashIterator<QPushButton*, int> iter(m_exportBtnHash);
while(iter.hasNext())
{
iter.next();
m_exportBtnHash.remove(iter.key());
}
m_exportBtnHash.clear();
m_dataRowHash.clear();
initWidget();
}
void CStatisticsWidget::updateItem(const QString& key)
{
if(m_dataRowHash.contains(key))
{
int row = m_dataRowHash.value(key);
SoftwareInfo info;
if(DatabaseManager::Instance()->ReadSoftwareInfo(key, info))
{
for (int i = 0; i < tableWidget->columnCount(); i++)
{
QTableWidgetItem* item = tableWidget->item(row, i);
if(!item) continue;
switch(i)
{
case 0:
item->setText(info.name);
break;
case 1:
item->setText(info.version);
break;
case 2:
item->setText(QString::number(info.installNum));
break;
case 3:
item->setText(QString::number(info.uninstalledNum));
break;
case 4:
item->setText(info.category);
break;
default:
break;
}
}
}
}
else
{
updateData();
}
}
void CStatisticsWidget::removeItem(const QString& key, int nRow)
{
if(m_dataRowHash.contains(key))
{
int row = m_dataRowHash.value(key);
tableWidget->removeRow(row);
m_dataRowHash.remove(key);
//删除一行后,将位于改行之后的数据的行号-1
QHash<QString, int> rowHash = m_dataRowHash;
QHashIterator<QString, int> iter(rowHash);
while(iter.hasNext())
{
iter.next();
if(iter.value() > row)
{
m_dataRowHash.insert(key, iter.value() - 1);
}
}
}
}
void CStatisticsWidget::addItem(const QString& key)
{
if(!m_dataRowHash.contains(key))
{
int rowCount = tableWidget->rowCount();
tableWidget->setRowCount(rowCount + 1);
SoftwareInfo info;
DatabaseManager::Instance()->ReadSoftwareInfo(key, info);
for (int i = 0; i < 6; i++)
{
SetItem(rowCount, i, info);
}
m_dataRowHash.insert(key, rowCount);
}
}
void CStatisticsWidget::exportAll()
{
QString path = QFileDialog::getSaveFileName(this, QString::fromLocal8Bit("导出"),
QApplication::applicationDirPath(), tr("Excel (*.xml)"));
if(path.isEmpty())
return;
QString columnNames[6] = {""};
int columnWidths[6] = {100, 100, 100, 100, 100};
QStringList contentList;
int rowCount = tableWidget->rowCount();
int columnCount = tableWidget->columnCount() - 1;
for (int i = 0; i < rowCount; i++)
{
QStringList content;
for (int j = 0; j < columnCount; j++)
{
if(columnNames[j].isEmpty()){
columnNames[j] = tableWidget->horizontalHeaderItem(j)->text();
columnWidths[j] = tableWidget->columnWidth(j);
}
content.append(tableWidget->item(i, j)->text());
}
contentList.append(content.join(";"));
}
if(ExcelHelper::Instance()->ToExcel(path, QString::fromLocal8Bit("软件安装信息统计"),
QString::fromLocal8Bit("软件信息统计"), columnNames, columnWidths, columnCount, contentList))
{
QMessageBox::information(this, QString::fromLocal8Bit("信息"),
QString::fromLocal8Bit("导出信息成功"),
QString::fromLocal8Bit("确定"));
}
else
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"),
QString::fromLocal8Bit("导出信息失败"),
QString::fromLocal8Bit("确定"));
}
return;
QHash<int, QStringList> data;
for (int i = 0; i < 10000; i++)
{
QStringList cells;
for (int j = 0; j < 6; j++)
{
cells << QString("%1%2").arg(i).arg(QString::number(j+10, 16).toUpper());
}
data.insert(i, cells);
}
QString fileName = QApplication::applicationDirPath() + "/Database/export.xml";
qDebug() << QString::fromLocal8Bit("数据量:%1条").arg(data.count());
qDebug() << QString::fromLocal8Bit("开始时间:") << QDateTime::currentDateTime().toString("yyyy-HH-MM hh:mm:ss zzz");
ExcelHelper::Instance()->ToExcel(fileName, data);
QDateTime::currentDateTime().toString("yyyy-HH-MM hh:mm:ss zzz");
qDebug() << QString::fromLocal8Bit("结束时间:") << QDateTime::currentDateTime().toString("yyyy-HH-MM hh:mm:ss zzz");
}
|
//
// Created by tudom on 2019-12-31.
//
#pragma once
#include <exception>
#include <string>
#include "../_api.hpp"
namespace info::dynamite {
struct INFO_DYNAMITE_API no_such_function : std::exception {
const char* what[[nodiscard]]() const noexcept override;
no_such_function(std::string) noexcept;
private:
std::string _function;
};
}
|
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <functional>
#include <numeric>
#include <sstream>
typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
#define PI 3.1415926535897932384626433832795
#define sqr(x) ((x)*(x))
using namespace std;
typedef LL Matr[2][2];
inline void Mul(Matr& r, const Matr& x, const Matr& y, LL m) {
r[0][0] = (x[0][0] * y[0][0] + x[0][1] * y[1][0]) % m;
r[0][1] = (x[0][0] * y[0][1] + x[0][1] * y[1][1]) % m;
r[1][0] = (x[1][0] * y[0][0] + x[1][1] * y[1][0]) % m;
r[1][1] = (x[1][0] * y[0][1] + x[1][1] * y[1][1]) % m;
}
LL Fib(LL p, LL nn) {
--p;
Matr c;
Matr r;
r[0][1] = r[1][0] = 0;
r[1][1] = r[0][0] = 1;
Matr x;
x[1][1] = 0;
x[0][1] = x[0][0] = x[1][0] = 1;
while (p) {
if (p & 1) {
Mul(c, r, x, nn);
memcpy(r, c, sizeof(x));
}
Mul(c, x, x, nn);
memcpy(x, c, sizeof(x));
p >>= 1;
}
return r[0][0];
}
LL Calc(LL n) {
LL nn = n;
vector<LL> div;
vector<LL> divc;
for (LL i = 2; i * i <= n; ++i)
if (n % i == 0) {
div.push_back(i);
divc.push_back(0);
while (n % i == 0) {
n /= i;
++divc.back();
}
}
if (n > 1) {
div.push_back(n);
divc.push_back(1);
}
if (divc.size() == 1 && divc.back() == 1) { //prime
if (nn == 2) return 3;
if (nn == 3) return 8;
if (nn == 5) return 20;
LL p = Fib(nn + 1, nn);
if (p == 0) {
LL dd = nn + 1, ans = dd;
for (LL i = 1; i * i <= dd; ++i) if (dd % i == 0) {
if (i < ans) {
LL p1 = Fib(i, nn);
if (p1 == 0) ans = i;
}
if (dd / i < ans) {
LL p1 = Fib(dd / i, nn);
LL p2 = Fib(dd / i + 1, nn);
if (p1 == 0) ans = dd / i;
}
}
LL j = 1;
while (true) {
LL p1 = Fib(ans * j + 1, nn);
if (p1 == 1) return ans * j;
++j;
}
} else {
LL dd = nn - 1, ans = dd;
for (LL i = 1; i * i <= dd; ++i) if (dd % i == 0) {
if (i < ans) {
LL p1 = Fib(i, nn);
LL p2 = Fib(i + 1, nn);
if (p1 == 0) ans = i;
}
if (dd / i < ans) {
LL p1 = Fib(dd / i, nn);
LL p2 = Fib(dd / i + 1, nn);
if (p1 == 0) ans = dd / i;
}
}
LL j = 1;
while (true) {
LL p1 = Fib(ans * j + 1, nn);
if (p1 == 1) return ans * j;
++j;
}
return ans;
}
} else
if (divc.size() == 1) { // prime^k
LL ans = Calc(div[0]);
for (LL i = 1; i < divc[0]; ++i) ans = ans * div[0];
return ans;
} else {
LL ans = 1;
for (LL i = 0; i < div.size(); ++i) {
LL x = 1;
for (LL j = 0; j < divc[i]; ++j) x *= div[i];
LL subans = Calc(x);
ans = ans / __gcd(ans, subans) * subans;
}
return ans;
}
}
int main() {
freopen("fibonacci.in", "r", stdin);
freopen("fibonacci.out", "w", stdout);
/*
for (int r = 2; r <= 3000; ++r) {
int f1 = 0;
int f2 = 1;
int it = 0;
while (true) {
++it;
int f3 = (f2 + f1) % r;
f1 = f2;
f2 = f3;
cout << f3 << " ";
if (f1 == 0 && f2 == 1) break;
}
cout << endl;
cout << r << ": " << it << endl;
if (it != Calc(r)) {
cerr << "ERROR: " << r << endl;
}
}
*/
int n;
cin >> n;
cout << Calc(n) << endl;
return 0;
}
|
/*
Name: ÃÔ;µÄţţ
Copyright:
Author: Hill bamboo
Date: 2019/8/15 14:08:29
Description: ����
�ܽ᣺
����ɶʱ����⣬��ô����
*/
#include <bits/stdc++.h>
using namespace std;
char d[4] = {'N', 'E', 'S', 'W'};
int main() {
int n; scanf("%d", &n);
string mm; cin >> mm;
int ans = 0;
for (int i = 0; i < n; ++i) {
if (mm[i] == 'L') ans = (ans + 3) % 4;
else ans = (ans + 1) % 4;
}
printf("%c\n", d[ans]);
return 0;
}
|
#pragma once
#include "Inputs.h"
#include "Constants.h"
#include "SceneManager.h"
#include "SplashScreen.h"
#include "Menu.h"
#include "Play.h"
#include "Ranking.h"
class GameController
{
private:
Inputs inputs;
SceneManager * actualScene;
public:
bool isRunning;
GameStates gameState;
PlayerRankingInfo newPlayerRankingInfo;
GameController();
void GoMenu();
void GoPlay();
void GoRankingAfterPlay();
void GoRankingAfterMenu();
void Run();
void Draw();
~GameController();
};
|
#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
double L,cost;
char stype,type;
cin>>L>>type>>stype;
if (stype=='s')
switch(type){
case 90:cost=5.82*L*0.95;break;
case 93:cost=5.96*L*0.95;break;
case 97:cost=6.36*L*0.95;break;
default:cost=5.59*L*0.95;
}
else switch(type){
case 90:cost=5.82*L*0.97;break;
case 93:cost=5.96*L*0.97;break;
case 97:cost=6.36*L*0.97;break;
default:cost=5.59*L*0.97;}
cout<<fixed<<setprecision(2)<<cost<<endl;
cout<<setiosflags(ios::scientific)<<12345.0<<endl;
cout<<setiosflags(ios::fixed)<<setprecision(3)<<12345.0<<endl;
}
|
#ifndef CHUFFED_MDDOPTS_H
#define CHUFFED_MDDOPTS_H
#include <string>
class MDDOpts {
public:
enum ExplAlg { E_MINIMAL, E_GREEDY, E_NAIVE };
enum ExplStrat { E_TEMP, E_KEEP };
enum Decomp { D_PROP, D_DOMAIN, D_TSEITIN };
MDDOpts() : expl_alg(E_GREEDY), expl_strat(E_KEEP), decomp(D_PROP) {}
MDDOpts(const MDDOpts& o) : expl_alg(o.expl_alg), expl_strat(o.expl_strat), decomp(o.decomp) {}
void parse_arg(const std::string& arg) {
if (arg == "explain_minimal") {
expl_alg = E_MINIMAL;
} else if (arg == "explain_greedy") {
expl_alg = E_GREEDY;
} else if (arg == "discard_explanations") {
expl_strat = E_TEMP;
} else if (arg == "store_explanations") {
expl_strat = E_KEEP;
}
}
ExplAlg expl_alg;
ExplStrat expl_strat;
Decomp decomp;
};
#endif
|
#include <iostream>
//A pointer is just an adress of memory.
//type of the pointer do not matter, it is always an int (memory Adress).
int main() {
void* ptr1 = nullptr; // 0 Is not a valid memory adress = NULL
int var = 8;
int* ptr2 = &var; // we storage the adress of var in ptr2
*ptr2 = 10;
char* buffer = new char[8]; // buffer is a pointer of 8 bytes
memset(buffer, 3, 8); // we assign 3 to the entire block of memory
char** ptr3 = &buffer; // we assignt to ptr3 the direction of the buffer pointer (pointer of a pointer)
delete[] buffer; // delete memory
std::cout << var; // result 10
std::cin.get();
}
|
#include "doublecalendar.h"
#include "ui_doublecalendar.h"
DoubleCalendar::DoubleCalendar(QWidget *parent) :
QDialog(parent),
ui(new Ui::DoubleCalendar)
{
ui->setupUi(this);
}
DoubleCalendar::~DoubleCalendar(){
delete ui;
}
void DoubleCalendar::setDays(QDate init,QDate end){
ui->calendar_init->setSelectedDate(init);
ui->calendar_end->setSelectedDate(end);
ui->label_init->setText("Fecha desde: "+init.toString());
ui->label_end->setText("Fecha desde: "+end.toString());
}
void DoubleCalendar::on_save_clicked(){
if(ui->calendar_init->selectedDate().daysTo(ui->calendar_end->selectedDate())<0){
// error: la fecha inicial es mayor a la final
ui->error_label->setText("<font color='red'>La fecha inicial debe ser anterior a la fecha final.</font>");
}else{
// guardar
emit newDays(ui->calendar_init->selectedDate(),ui->calendar_end->selectedDate());
close();
}
}
void DoubleCalendar::on_cancel_clicked(){
close();
}
|
/* -*-mode:c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
#include "tracker.hh"
#include <iomanip>
#include <sstream>
#include <iostream>
#include <cmath>
#include <numeric>
#include <chrono>
#include "thunk/ggutils.hh"
#include "thunk/thunk_reader.hh"
#include "util/optional.hh"
#include "util/exception.hh"
#include "util/timeit.hh"
#include "util/path.hh"
#include "util/digest.hh"
using namespace std;
using namespace std::chrono;
using namespace gg;
using namespace gg::thunk;
using ReductionResult = gg::cache::ReductionResult;
void Tracker::print_status() const
{
stringstream ss;
ss << "Completed: " << target_hash_ << endl;
cout << ss.str();
}
Tracker::Tracker( const std::string & target_hashes, shared_ptr<TCPConnection> connection )
: target_hash_(target_hashes), connection_(connection)
{
remaining_targets_.insert(target_hash_);
cerr << "\u2192 Loading the thunks... ";
auto graph_load_time = time_it<milliseconds>(
[this] ()
{
dep_graph_.add_thunk( target_hash_ );
unordered_set<string> thunk_o1_deps = dep_graph_.order_one_dependencies( target_hash_ );
job_queue_.insert( job_queue_.end(), thunk_o1_deps.begin(), thunk_o1_deps.end() );
} ).count();
cerr << " done (" << graph_load_time << " ms)." << endl;
}
void Tracker::finalize_execution( const string & old_hash,
vector<ThunkOutput> && outputs,
const float cost )
{
running_jobs_.erase( old_hash );
const string main_output_hash = outputs.at( 0 ).hash;
Optional<unordered_set<string>> new_o1s = dep_graph_.force_thunk( old_hash, move ( outputs ) );
estimated_cost_ += cost;
if ( new_o1s.initialized() ) {
job_queue_.insert( job_queue_.end(), new_o1s->begin(), new_o1s->end() );
if ( gg::hash::type( main_output_hash ) == gg::ObjectType::Value ) {
remaining_targets_.erase( dep_graph_.original_hash( old_hash ) );
}
finished_jobs_++;
}
}
string Tracker::next()
{
string job;
if (!job_queue_.empty()) {
job = job_queue_.front();
running_jobs_.insert( job );
job_queue_.pop_front();
}
return job;
}
string Tracker::reduce()
{
if (not is_finished())
{
throw runtime_error( "unhandled poller failure happened, job is not finished" );
}
const string final_hash = dep_graph_.updated_hash( target_hash_ );
const Optional<ReductionResult> answer = gg::cache::check( final_hash );
if ( not answer.initialized() ) {
throw runtime_error( "internal error: final answer not found for " + target_hash_ );
}
return answer->hash;
}
|
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
#include <cstdlib>
#include "node.h"
#include <iostream>
using namespace std;
/******************************************************
** Class: Linked_List
** Purpose: A class to hold a pointer to the head node
** of a linked list as well as an integer representing
** how long the linked list is. It will also contain
** all of the necessary functions to give the linked
** list its real world functionality.
******************************************************/
class Linked_List {
private:
unsigned int length = 0;
Node * head = NULL;
public:
//! TEMPLATE FOR FUNCTION HEADER, DO NOT TOUCH
/******************************************************
** Function:
** Description:
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: NA
******************************************************/
//! FUNCTIONS OF THE CLASS
/******************************************************
** Function: Linked_List
** Description: Simple constructor for the linked list
** class.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Create the linked list, filling it
** with its members based on user input and setting its
** length respecitvely.
******************************************************/
Linked_List(); //TODO// Code constructor
//! ACCESSORS AND MUTATOTRS
/******************************************************
** Function: get_length
** Description: Returns the length of the linked list.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Return an integer to show the length
** of the linked list.
******************************************************/
int get_length(); //TODO// Code accessor
/******************************************************
** Function: get_node
** Description: A funtion that returns a pointer to the
** node at the specified index.
** Parameters: int
** Pre-conditions: Take in an integer to represent the
** index that the user wishes to retrieve the node at.
** Post-conditions: Unchanged, returns a pointer to the
** requested node.
******************************************************/
Node * get_node(int); //TODO// Code get_node
//! FUNCTIONS OF THE LINKED LIST
/******************************************************
** Function: print
** Description: Simple function which parses through
** the linked list and prints its members to the screen.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Prints the linked list data members
** to the screen.
******************************************************/
void print(); //TODO// Code print
/******************************************************
** Function: clear
** Description: Clears the linked list, frees memory,
** and resets the length and head member varaibles.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Clears all memory from the heap and
** resets all the member variables.
******************************************************/
void clear(); //TODO// Code clear
/******************************************************
** Function: push_front
** Description: Function to push a new node onto the
** front of the linked list.
** Parameters: int
** Pre-conditions: Take in an integer value to show the
** data to be stored to the new node.
** Post-conditions: Return an integer to represent the
** new length of the linked list.
******************************************************/
unsigned int push_front(int); //TODO// Code push_front
/******************************************************
** Function: push_back
** Description: Function to push a new node onto the
** back of the linked list.
** Parameters: int
** Pre-conditions: Take in an integer value to show the
** data to be stored to the new node.
** Post-conditions: Return an integer to represent the
** new length of the linked list.
******************************************************/
unsigned int push_back(int); //TODO// Code push_back
/******************************************************
** Function: insert
** Description: Function to insert a new node at any
** index within the linked list.
** Parameters: int, unsigned int
** Pre-conditions: Take in an integer value to show the
** data to be stored to the new node as well as an
** integer value to show which index to insert the node
** at.
** Post-conditions: Return an integer to represent the
** new length of the linked list.
******************************************************/
unsigned int insert(int, unsigned int); //TODO// Code insert
/******************************************************
** Function: sort_ascending
** Description: Passthrough function for when the user
** decides to sort their linked list in ascending order.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Resorts the linked list to be in
** ascending order.
******************************************************/
void sort_ascending(); //TODO// Code sort_ascending
/******************************************************
** Function: sort_descending
** Description: Passthrough function for when the user
** decides to sort their linekd list in descending
** order.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Resorts the linked list to be in
** descending order.
******************************************************/
void sort_descending(); //TODO// Code sort_descending
/******************************************************
** Function: merge
** Description: Function which merges a left and a right
** linked list head.
** Parameters: Node *, Node *, bool
** Pre-conditions: Take in two node pointers to the left
** and right linked lists, as well as a boolean value
** to represent if it is to be sorted in descending
** order or not.
** Post-conditions: Merges the two linked lists in the
** correct order.
******************************************************/
Node * merge(Node *, Node *, bool);
/******************************************************
** Function: merge_sort
** Description: Hub function for the recursive merge
** sort algorithm.
** Parameters: Node **, bool
** Pre-conditions: Take in a pointer to the node pointer
** to the head node as well as a boolean value to show
** if the sort is to be in descending order or not.
** Post-conditions: Call the correct recursive functions
** to sort the linked list.
******************************************************/
void merge_sort(Node **, bool);
/******************************************************
** Function: split_linked_list
** Description: Function which splits the given linked
** list into two halves.
** Parameters: Node *, NOde **, Node **
** Pre-conditions: Take in a node pointer to the head of
** the linked list, as well as two pointers to either
** node pointers to the sides of the linked list.
** Post-conditions: Change the right and left node
** pointers to be the appropriate nodes.
******************************************************/
void split_linked_list(Node *, Node **, Node **);
/******************************************************
** Function: prime_number_find
** Description: Function to find and print all of the
** prime numbers in the linked list, and includes any
** repeats.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Prints out all of the prime numbers
** in the linked list.
******************************************************/
void prime_number_find();
/******************************************************
** Function: choose_order
** Description: Hub function for the user to choose the
** order they wish the program to sort their linked list
** in.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Call on the appropriate function
** based on what the user chooses.
******************************************************/
void choose_order();
/******************************************************
** Function: again
** Description: Hub function for the user to choose if
** they want to run the program again to make a new
** linked list.
** Parameters: NA
** Pre-conditions: NA
** Post-conditions: Return a boolean value to represent
** if the user wants to run it again.
******************************************************/
bool again();
//! ERROR HANLDING FUNCTIONS
/******************************************************
** Function: is_int
** Description: Simple error handling function which
** tests a string to see if it is an integer or not, and
** returns a boolean value to reflect that.
** Parameters: string
** Pre-conditions: Take in a string to test.
** Post-conditions: Unchanged, return a boolean value
** of true if the string is an integer or a false if
** the string is not a valid integer.
******************************************************/
bool is_int(string);
};
#endif
|
#pragma once
#include "plbase/PluginBase.h"
#include <game_sa\RenderWareTypes.h>
#pragma pack(push, 4)
class PLUGIN_API CScene
{
public:
RpWorld *m_pRpWorld;
RwCamera *m_pRwCamera;
};
#pragma pack(pop)
extern PLUGIN_API CScene &Scene;
|
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define MAXI 1000000001
#define LIMIT1 100000
#define LIMIT2 20
#define LIMIT3 3*LIMIT2
#define getint(n) scanf("%d",&n)
#define putintn(n) printf("%d\n",n)
#define putintc(a) printf("%d,",a);
using namespace std;
struct range
{
int s,e;
}ranges[LIMIT1];
int times[LIMIT2];
int binary_search(int l,int u, int k)
{
int mid;
while(l<=u)
{
mid=(l+u)/2;
if(times[mid]==k)
return mid;
if(times[mid]<k)
l=mid+1;
else
u=mid-1;
}
return mid;
}
int main()
{
int n,s,e,q,k,count=0,t;
getint(n);
for(int i=0;i<n;i++)
{
getint(s);
getint(e);
ranges[i].s=s;
ranges[i].e=e;
}
getint(q);
for(int i=0;i<q;i++)
{
count=0;
getint(k);
for(int j=0;j<k;j++)
{
getint(times[j]);
}
sort(times,times+k);
for(int j=0;j<n;j++)
{
s=binary_search(0,k-1,ranges[j].s);
if(times[s]>=ranges[j].s && times[s]<=ranges[j].e)
count++;
else if(times[s]>ranges[j].e)
{
if(s-1>=0 && (times[s-1]>=ranges[j].s && times[s-1]<=ranges[j].e))
count++;
}
else if(times[s]<ranges[j].s)
{
if(s+1<k && (times[s+1]>=ranges[j].s && times[s+1]<=ranges[j].e))
count++;
}
}
putintn(count);
}
return 0;
}
|
#ifndef TACHE_H
#define TACHE_H
#include <iostream>
#include <QString>
#include "timing.h"
using namespace std;
using namespace TIME;
//Statut = 0 => Tache non programmée, à venir. Date d'échéance non dépassée
//Statut = -1 => Tache non programmée, date d'échéance dépassée
//Statut = 1 => Tache programmée/réalisée
class Tache {
private:
int statut;
QString identificateur;
QString titre;
Tache** precedence;
int nbPrec;
int nbPrecMax;
QDate dispo;
QDate echeance;
//Tache(const QString& id, const QString& t, const QDate& disponible, const QDate& ech) : statut(0),identificateur(id), titre(t),dispo(disponible), echeance(ech), precedence(0){};
//Tache(const Tache& t);
Tache& operator=(const Tache& t);
public:
Tache(const QString& id=0, const QString& t=0, const QDate& disponible=QDate(0,0,0), const QDate& ech=QDate(0,0,0)) : statut(0), identificateur(id), titre(t), precedence(0),dispo(disponible), echeance(ech){}
Tache(const Tache& t);
int getStatut() const{return statut;}
QString getId() const {return identificateur;}
QString getTitre() const {return titre;}
Tache** getPrecedence() const{return precedence;}
int getStatutPrecedence()const;
QDate getDispo()const{return dispo;}
QDate getEcheance()const{return echeance;}
void setStatut(int s){statut=s;}
void addPrecedence(Tache* t);
void rmPrecedence(Tache* t);
virtual void afficher()=0;
virtual QString getType() const=0;
virtual ~Tache(){}
};
class TUnitaire : public Tache{
private:
bool preemptive;
Duree duree;
public:
TUnitaire(const QString& id, const QString& t, const QDate& disponible, const QDate& ech, bool premp, const Duree& dur) : Tache(id,t,disponible,ech),preemptive(premp),duree(dur){}
TUnitaire():Tache(),preemptive(0),duree(0){}
bool getPreemptive()const{return preemptive;}
Duree getDuree()const{return duree;}
void setDuree(const Duree& d){duree=d;}
void afficher(){cout<<1;}
QString getType() const{return "unitaire";}
~TUnitaire(){}
};
class TComposite : public Tache{
private:
Tache** sousTaches;
int nb;
int nbMax;
public :
class IteratorSTL{
private:
Tache** currentTache;
public:
IteratorSTL(Tache** u): currentTache(u){}
IteratorSTL operator++(){
++currentTache;
return *this;
};
IteratorSTL operator--(){
--currentTache;
return *this;
};
bool operator!=(const IteratorSTL& it) const {return currentTache!= it.currentTache;}
const Tache& operator*() const {return **currentTache;}
};
TComposite(const QString& id, const QString& t, const QDate& disponible, const QDate& ech) : Tache(id,t,disponible,ech),sousTaches(0),nb(0),nbMax(0){}
TComposite():Tache(),sousTaches(0),nb(0),nbMax(0){}
Tache** getSousTaches()const {return sousTaches;}
Tache* getSousTache(const QString& id)const;
void ajouterSousTache(const QString& desc, const QString& id, const QString& t,const Duree& du, const QDate& dispo, const QDate& deadline,bool preempt );
void addSousTache(Tache* t);
void afficher(){cout<<2;}
~TComposite(){delete[] sousTaches;}
IteratorSTL begin() const;
IteratorSTL end() const;
QString getType()const{return "composite";}
};
class TacheFactory {
public:
static Tache* NewTache(const QString& description ,const QString& id=0,const QString& t=0,const QDate& disponible=QDate(0,0,0), const QDate& ech=QDate(0,0,0),const Duree& duree=0, bool preemp=0){
if(description=="unitaire")
return new TUnitaire(id,t,disponible,ech,preemp,duree);
if(description=="composite")
return new TComposite(id,t,disponible,ech);
return NULL;
}
};
#endif // TACHE_H
|
//知识点:单调栈
/*
维护一个单调递减的单调栈
栈中的牛都是没有 仰望对象 的牛
对于一个新加入的牛,
while循环,来弹出栈顶身高小于它的牛
并使 被弹出牛的仰望对象 = 新牛
然后将新牛加入栈中
最后输出即可
*/
#include<cstdio>
#include<stack>
using namespace std;
const int MARX = 1e5+10;
int n,h[MARX],ans[MARX];
stack <int> s;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&h[i]);
while(!s.empty())
{
if(h[s.top()]>=h[i]) break;
ans[s.top()]=i;//被弹出牛的仰望对象 = 新牛
s.pop();//while循环,来弹出栈顶身高小于它的牛
}
s.push(i);//入栈
}
for(int i=1;i<=n;i++)
printf("%d\n",ans[i]);
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
#define dbg(x) cout << (#x) << " is " << (x) << endl;
#define dbg2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << y << endl;
#define dbgitem(x) \
for (auto asdf = x.begin(); asdf != x.end(); asdf++) asdf->print(); \
cout << endl;
#define MAXN 100005
int inf = 2000000000;
struct segment {
int h, l, r;
segment() {}
segment(int h, int l, int r) : h(h), l(l), r(r) {}
bool operator<(const segment &s) const {
return h < s.h;
}
};
struct part {
int l, r, f;
segment s;
part(int l, int r, int f, segment s) : l(l), r(r), f(f), s(s) {}
bool operator<(const part &p) const {
return l < p.l;
}
void print() const {
printf("l=%d, r=%d, f=%d, h=%d\n", l, r, f, s.h);
}
};
set<part> sweep;
segment s[MAXN];
int main() {
int n, t;
scanf("%d %d", &n, &t);
for (int i = 0; i < n; i++) {
int h, l, r;
scanf("%d %d %d", &h, &l, &r);
s[i] = segment(h, l, r);
}
s[n] = segment(t, -inf, inf); // at the very top
sort(s, s + n);
part bottom(-inf, inf, inf, segment(0, -inf, inf));
part left(-inf - 1, -inf, 0, segment(0, -inf - 1, -inf));
part right(inf, inf + 1, 0, segment(0, inf, inf + 1));
sweep.insert(bottom);
sweep.insert(left);
sweep.insert(right);
for (int i = 0; i <= n; i++) {
int h = s[i].h, l = s[i].l, r = s[i].r;
dbg(h);
part p(l, r, 0, s[i]);
set<part>::iterator it = sweep.upper_bound(p), jt, kt;
it--; // first one <= p
jt = it;
set<part>::iterator lt = jt, rt = jt;
lt--; // left of it
rt++; // right of it so (lt, jt, rt)
while (jt->l < r) { // some overlap between jt and p
// dbg2(jt->l, jt->r);
if (!(lt->s.r > max(jt->s.l, l) && jt->s.h < lt->s.h && lt->s.h < h) && // lt catches from p
!(rt->s.l < min(jt->s.r, r) && jt->s.h < rt->s.h && rt->s.h < h)) { // rt catches from p
p.f = max(p.f, min(jt->f, min(jt->s.r, r) - max(jt->s.l, l))); // cand flow through jt
} else
cout << (lt->s.r > max(jt->s.l, l) && jt->s.h < lt->s.h && lt->s.h < h) << "," << jt->l<< endl;
lt++;
jt++;
rt++;
}
kt = jt;
kt--;
part start = *it, end = *kt; // start, end are inclusive bounds of what was erased
sweep.erase(it, jt); // everything that overlapped
if (start.l < l) {
sweep.insert(part(start.l, l, start.f, start.s));
}
if (end.r > r) {
sweep.insert(part(r, end.r, end.f, end.s));
}
sweep.insert(p);
dbgitem(sweep);
}
set<part>::iterator it = sweep.begin();
it++;
printf("%d\n", it->f);
}
|
#ifndef GNLAYERMAIN_H
#define GNLAYERMAIN_H
#include "GnLayerBackground.h"
class GnLayerMain : public GnLayer
{
protected:
GnLayerBackground* mpBackground;
public:
GnLayerMain();
virtual ~GnLayerMain(){};
bool CreateBackgroundFromFile(const gchar* fileName);
inline GnLayerBackground* GetBackground() {
return mpBackground;
}
inline void SetBackground(GnLayerBackground* val) {
mpBackground = val;
}
};
#endif // GNLAYERMAIN_H
|
//class RefWinApi
//import WinApi
//#using <mscorlib.dll>
//using namespace System;
using namespace System::Runtime::InteropServices;
namespace RefWinApi
{
//Mesagebox
[DllImport("user32.dll",CharSet=CharSet::Auto)]
int MessageBox(void* hWnd,wchar_t* text,wchar_t* caption,unsigned int type);
//HANDLE OpenProcess(
// DWORD dwDesiredAccess,// access flag
// BOOL bInheritHandle, // handle inheritance flag
// DWORD dwProcessId // process identifier
// );
[DllImport("kernel32.dll")]
void* OpenProcess(unsigned int dwDesiredAccess, unsigned int bInheritHandle, unsigned int dwProcessId);
//BOOL CloseHandle(
// HANDLE hObject // handle to object to close
// );
[DllImport("kernel32.dll")]
unsigned int CloseHandle(void* hObject);
//BOOL WriteProcessMemory(
// HANDLE hProcess, // handle to process whose memory is written to
// LPVOID lpBaseAddress, // address to start writing to
// LPVOID lpBuffer, // pointer to buffer to write data to
// DWORD nSize, // number of bytes to write
// LPDWORD lpNumberOfBytesWritten // actual number of bytes written
// );
[DllImport("kernel32.dll")]
int WriteProcessMemory(void* hProcess, void* lpBaseAddress, unsigned int lpBuffer[], unsigned int nSize, void* lpNumberOfBytesWritten);
//BOOL ReadProcessMemory(
// HANDLE hProcess, // handle of the process whose memory is read
// LPCVOID lpBaseAddress, // address to start reading
// LPVOID lpBuffer, // address of buffer to place read data
// DWORD nSize, // number of bytes to read
// LPDWORD lpNumberOfBytesRead // address of number of bytes read
// );
[DllImport("kernel32.dll")]
int ReadProcessMemory(void* hProcess, void* lpBaseAddress, unsigned int lpBuffer[], unsigned int nSize, void* lpNumberOfBytesRead);
//member
//
//unsigned int PROCESS_ALL_ACCESS=0x001F0FFF;
[DllImport("user32.dll")]
long SendMessage(void* hwnd,unsigned int meg,unsigned int key,unsigned int info);
[DllImport("user32.dll")]
long PostMessage(void* hwnd,unsigned int meg,unsigned int key,unsigned int info);
[DllImport("user32.dll")]
void* FindWindowA(void* cname,void* wname);
[DllImport("User32.dll", CharSet = CharSet::Auto)]
int GetWindowText(void* hWnd,wchar_t* text, int nMaxCount);
//
}//end of class RefWinApi
|
#include <stdio.h>
#include <ctype.h>
char _I_Buffer[2110],_O_Buffer[2110],*_I_pos = _I_Buffer,*_O_pos = _O_Buffer;
inline int get()
{
register int res = 0, k = 1;
while (!isdigit(*_I_pos))
if (*_I_pos++ == '-')k = 0;
do res = (res << 3) + (res << 1), res += (*_I_pos++) & 15;while (isdigit(*_I_pos));
return k ? res : -res;
}
inline void put(register int n)
{
static char _buf[20];
register char* _pos(_buf);
if (n < 0) {*_O_pos++ = '-';n = -n;}
do *_pos++ = 48 + n % 10;while (n /= 10);
while (_pos != _buf)*_O_pos++ = *--_pos;
}
inline void put(register char ch){*_O_pos++ = ch;}
int main()
{
register int n,a,b;
fread(_I_Buffer, 1, 2110, stdin);
n = get();
while (n--) a = get(), b = get(), put(a + b), put('\n');
fwrite(_O_Buffer, 1, _O_pos - _O_Buffer, stdout);
}
|
// Created on: 1993-08-18
// Created by: Christophe MARION
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _HLRBRep_LineTool_HeaderFile
#define _HLRBRep_LineTool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
#include <GeomAbs_Shape.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <Standard_Boolean.hxx>
#include <GeomAbs_CurveType.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Parab.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
class Standard_OutOfRange;
class Standard_NoSuchObject;
class Standard_DomainError;
class gp_Pnt;
class gp_Vec;
class Geom_BezierCurve;
class Geom_BSplineCurve;
//! The LineTool class provides class methods to
//! access the methodes of the Line.
class HLRBRep_LineTool
{
public:
DEFINE_STANDARD_ALLOC
static Standard_Real FirstParameter (const gp_Lin& C);
static Standard_Real LastParameter (const gp_Lin& C);
static GeomAbs_Shape Continuity (const gp_Lin& C);
//! If necessary, breaks the line in intervals of
//! continuity <S>. And returns the number of
//! intervals.
static Standard_Integer NbIntervals (const gp_Lin& C, const GeomAbs_Shape S);
//! Sets the current working interval.
static void Intervals (const gp_Lin& C, TColStd_Array1OfReal& T, const GeomAbs_Shape Sh);
//! Returns the first parameter of the current
//! interval.
static Standard_Real IntervalFirst (const gp_Lin& C);
//! Returns the last parameter of the current
//! interval.
static Standard_Real IntervalLast (const gp_Lin& C);
static GeomAbs_Shape IntervalContinuity (const gp_Lin& C);
static Standard_Boolean IsClosed (const gp_Lin& C);
static Standard_Boolean IsPeriodic (const gp_Lin& C);
static Standard_Real Period (const gp_Lin& C);
//! Computes the point of parameter U on the line.
static gp_Pnt Value (const gp_Lin& C, const Standard_Real U);
//! Computes the point of parameter U on the line.
static void D0 (const gp_Lin& C, const Standard_Real U, gp_Pnt& P);
//! Computes the point of parameter U on the line with its
//! first derivative.
//! Raised if the continuity of the current interval
//! is not C1.
static void D1 (const gp_Lin& C, const Standard_Real U, gp_Pnt& P, gp_Vec& V);
//! Returns the point P of parameter U, the first and second
//! derivatives V1 and V2.
//! Raised if the continuity of the current interval
//! is not C2.
static void D2 (const gp_Lin& C, const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2);
//! Returns the point P of parameter U, the first, the second
//! and the third derivative.
//! Raised if the continuity of the current interval
//! is not C3.
static void D3 (const gp_Lin& C, const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3);
//! The returned vector gives the value of the derivative for the
//! order of derivation N.
//! Raised if the continuity of the current interval
//! is not CN.
//! Raised if N < 1.
static gp_Vec DN (const gp_Lin& C, const Standard_Real U, const Standard_Integer N);
//! Returns the parametric resolution corresponding
//! to the real space resolution <R3d>.
static Standard_Real Resolution (const gp_Lin& C, const Standard_Real R3d);
//! Returns the type of the line in the current
//! interval : Line, Circle, Ellipse, Hyperbola,
//! Parabola, BezierCurve, BSplineCurve, OtherCurve.
static GeomAbs_CurveType GetType (const gp_Lin& C);
static gp_Lin Line (const gp_Lin& C);
static gp_Circ Circle (const gp_Lin& C);
static gp_Elips Ellipse (const gp_Lin& C);
static gp_Hypr Hyperbola (const gp_Lin& C);
static gp_Parab Parabola (const gp_Lin& C);
static Handle(Geom_BezierCurve) Bezier (const gp_Lin& C);
static Handle(Geom_BSplineCurve) BSpline (const gp_Lin& C);
static Standard_Integer Degree (const gp_Lin& C);
static Standard_Integer NbPoles (const gp_Lin& C);
static void Poles (const gp_Lin& C, TColgp_Array1OfPnt& TP);
static Standard_Boolean IsRational (const gp_Lin& C);
static void PolesAndWeights (const gp_Lin& C, TColgp_Array1OfPnt& TP, TColStd_Array1OfReal& TW);
static Standard_Integer NbKnots (const gp_Lin& C);
static void KnotsAndMultiplicities (const gp_Lin& C, TColStd_Array1OfReal& TK, TColStd_Array1OfInteger& TM);
static Standard_Integer NbSamples (const gp_Lin& C, const Standard_Real U0, const Standard_Real U1);
static void SamplePars (const gp_Lin& C, const Standard_Real U0, const Standard_Real U1, const Standard_Real Defl, const Standard_Integer NbMin, Handle(TColStd_HArray1OfReal)& Pars);
protected:
private:
};
#include <HLRBRep_LineTool.lxx>
#endif // _HLRBRep_LineTool_HeaderFile
|
// Created on: 2016-04-07
// Copyright (c) 2016 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _IMeshData_Types_HeaderFile
#define _IMeshData_Types_HeaderFile
#include <NCollection_Sequence.hxx>
#include <NCollection_List.hxx>
#include <NCollection_Shared.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <TopoDS_Shape.hxx>
#include <NCollection_DefineAlloc.hxx>
#include <NCollection_StdAllocator.hxx>
#include <IMeshData_ParametersListArrayAdaptor.hxx>
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#include <NCollection_EBTree.hxx>
#include <Bnd_Box2d.hxx>
#include <NCollection_CellFilter.hxx>
#include <NCollection_IndexedDataMap.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <NCollection_IndexedMap.hxx>
#include <BRepMesh_Vertex.hxx>
#include <Bnd_B2d.hxx>
#include <BRepMesh_Circle.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_PairOfIndex.hxx>
#include <BRepMesh_Edge.hxx>
#include <memory>
#include <queue>
class IMeshData_Shape;
class IMeshData_Face;
class IMeshData_Wire;
class IMeshData_Edge;
class IMeshData_Curve;
class IMeshData_PCurve;
class IMeshData_Model;
class BRepMesh_VertexInspector;
class BRepMesh_CircleInspector;
#define DEFINE_INC_ALLOC \
DEFINE_NCOLLECTION_ALLOC \
void operator delete (void* /*theAddress*/) \
{ \
/*it's inc allocator, nothing to do*/ \
}
namespace IMeshData
{
//! Default size for memory block allocated by IncAllocator.
/**
* The idea here is that blocks of the given size are returned to the system
* rather than retained in the malloc heap, at least on WIN32 and WIN64 platforms.
*/
#ifdef _WIN64
const size_t MEMORY_BLOCK_SIZE_HUGE = 1024 * 1024;
#else
const size_t MEMORY_BLOCK_SIZE_HUGE = 512 * 1024;
#endif
typedef IMeshData_Edge* IEdgePtr;
typedef IMeshData_Face* IFacePtr;
typedef Handle(IMeshData_Edge) IEdgeHandle;
typedef Handle(IMeshData_Wire) IWireHandle;
typedef Handle(IMeshData_Face) IFaceHandle;
typedef Handle(IMeshData_Curve) ICurveHandle;
typedef Handle(IMeshData_PCurve) IPCurveHandle;
typedef IMeshData_ParametersListArrayAdaptor<ICurveHandle> ICurveArrayAdaptor;
typedef Handle(ICurveArrayAdaptor) ICurveArrayAdaptorHandle;
typedef NCollection_Shared<NCollection_EBTree<Standard_Integer, Bnd_Box2d> > BndBox2dTree;
typedef NCollection_UBTreeFiller<Standard_Integer, Bnd_Box2d> BndBox2dTreeFiller;
// Vectors
typedef NCollection_Shared<NCollection_Vector<IFaceHandle> > VectorOfIFaceHandles;
typedef NCollection_Shared<NCollection_Vector<IWireHandle> > VectorOfIWireHandles;
typedef NCollection_Shared<NCollection_Vector<IEdgeHandle> > VectorOfIEdgeHandles;
typedef NCollection_Shared<NCollection_Vector<IPCurveHandle> > VectorOfIPCurveHandles;
typedef NCollection_Shared<NCollection_Vector<IEdgePtr> > VectorOfIEdgePtrs;
typedef NCollection_Shared<NCollection_Vector<Standard_Boolean> > VectorOfBoolean;
typedef NCollection_Shared<NCollection_Vector<Standard_Integer> > VectorOfInteger;
typedef NCollection_Shared<NCollection_Vector<TopAbs_Orientation> > VectorOfOrientation;
typedef NCollection_Shared<NCollection_Vector<BRepMesh_Triangle> > VectorOfElements;
typedef NCollection_Shared<NCollection_Vector<BRepMesh_Circle> > VectorOfCircle;
typedef NCollection_Shared<NCollection_Array1<BRepMesh_Vertex> > Array1OfVertexOfDelaun;
typedef NCollection_Shared<NCollection_Vector<BRepMesh_Vertex> > VectorOfVertex;
// Sequences
typedef NCollection_Shared<NCollection_Sequence<Bnd_B2d> > SequenceOfBndB2d;
typedef NCollection_Shared<NCollection_Sequence<Standard_Integer> > SequenceOfInteger;
typedef NCollection_Shared<NCollection_Sequence<Standard_Real> > SequenceOfReal;
namespace Model
{
typedef std::deque<gp_Pnt, NCollection_StdAllocator<gp_Pnt> > SequenceOfPnt;
typedef std::deque<gp_Pnt2d, NCollection_StdAllocator<gp_Pnt2d> > SequenceOfPnt2d;
typedef std::deque<Standard_Real, NCollection_StdAllocator<Standard_Real> > SequenceOfReal;
typedef std::deque<Standard_Integer, NCollection_StdAllocator<Standard_Integer> > SequenceOfInteger;
}
// Lists
typedef NCollection_Shared<NCollection_List<Standard_Integer> > ListOfInteger;
typedef NCollection_Shared<NCollection_List<gp_Pnt2d> > ListOfPnt2d;
typedef NCollection_Shared<NCollection_List<IPCurveHandle> > ListOfIPCurves;
typedef NCollection_Shared<TColStd_PackedMapOfInteger> MapOfInteger;
typedef TColStd_MapIteratorOfPackedMapOfInteger IteratorOfMapOfInteger;
typedef NCollection_CellFilter<BRepMesh_CircleInspector> CircleCellFilter;
typedef NCollection_CellFilter<BRepMesh_VertexInspector> VertexCellFilter;
// Data Maps
template<typename Type>
struct WeakEqual
{
static Standard_Boolean IsEqual(const Type* theFirst,
const Type* theSecond)
{
return (theFirst == theSecond);
}
//! Computes a hash code for the given pointer, in the range [1, theUpperBound]
//! @param thePointer the pointer which hash code is to be computed
//! @param theUpperBound the upper bound of the range a computing hash code must be within
//! @return a computed hash code, in the range [1, theUpperBound]
static Standard_Integer HashCode (const Type* const thePointer, Standard_Integer theUpperBound)
{
return ::HashCode (thePointer, theUpperBound);
}
};
typedef NCollection_Shared<NCollection_DataMap<TopoDS_Shape, Standard_Integer, TopTools_ShapeMapHasher> > DMapOfShapeInteger;
typedef NCollection_Shared<NCollection_DataMap<IFacePtr, ListOfInteger, WeakEqual<IMeshData_Face> > > DMapOfIFacePtrsListOfInteger;
typedef NCollection_Shared<NCollection_Map<IEdgePtr, WeakEqual<IMeshData_Edge> > > MapOfIEdgePtr;
typedef NCollection_Shared<NCollection_Map<IFacePtr, WeakEqual<IMeshData_Face> > > MapOfIFacePtr;
typedef NCollection_Shared<NCollection_Map<BRepMesh_OrientedEdge> > MapOfOrientedEdges;
typedef NCollection_Shared<NCollection_Map<Standard_Real> > MapOfReal;
typedef NCollection_Shared<NCollection_IndexedDataMap<IFacePtr, ListOfIPCurves, WeakEqual<IMeshData_Face> > > IDMapOfIFacePtrsListOfIPCurves;
typedef NCollection_Shared<NCollection_DataMap<IFacePtr, Handle(MapOfIEdgePtr), WeakEqual<IMeshData_Face> > > DMapOfIFacePtrsMapOfIEdgePtrs;
typedef NCollection_Shared<NCollection_IndexedDataMap<BRepMesh_Edge, BRepMesh_PairOfIndex> > IDMapOfLink;
typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, ListOfInteger> > DMapOfIntegerListOfInteger;
typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, Standard_Integer> > MapOfIntegerInteger;
typedef NCollection_Shared<NCollection_IndexedMap<Standard_Real> > IMapOfReal;
typedef NCollection_Shared<NCollection_Array1<Standard_Integer> > Array1OfInteger;
}
#endif
|
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
using namespace std;
/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */
#define int long long
#define ld long double
#define F first
#define S second
#define P pair <int,int>
#define vi vector <int>
#define vs vector <string>
#define vb vector <bool>
#define all(x) x.begin(),x.end()
#define REP(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define REV(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define sp(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define mod (int)1e9+7
#define endl '\n'
/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */
const int N = 1e6 + 5;
char a[1001][1001];
vi Graph[N];
int vis[N];
int n, m;
int ans;
int row[] = {0, 0, 0, -1, 1};//E W N S;
int col[] = {0, 1, -1, 0, 0};
bool is_valid(int i, int j) {
return (i >= 0 && i <= n - 1 && j >= 0 && j <= m - 1);
}
P cord(char x) {
if (x == 'S')
return {1, 0};
if (x == 'N')
return { -1, 0};
if (x == 'E')
return {0, 1};
if (x == 'W')
return {0, -1};
return {0, 0};
}
void bfs(int src) {
queue <int> q;
q.push(src);
vis[src] = 1;
while (!q.empty()) {
int temp = q.front();
q.pop();
for (int to : Graph[temp]) {
if (!vis[to]) {
vis[to] = 1;
q.push(to);
}
}
}
}
void solve() {
cin >> n >> m;
REP(i, 0, n - 1) {
REP(j, 0, m - 1) {
cin >> a[i][j];
}
}
REP(i, 0, n - 1) {
REP(j, 0, m - 1) {
int u = (i * m) + j;
int v = -1;
int r = cord(a[i][j]).F + i;
int c = cord(a[i][j]).S + j;
if (is_valid(r, c)) {
v = (r * m) + c;
Graph[u].pb(v);
Graph[v].pb(u);
}
//cout << u << " " << v << endl;
}
}
// REP(i, 0, n * m - 1) {
// for (auto x : Graph[i])
// cout << x << " ";
// cout << endl;
// }
REP(i, 0, n * m - 1)
if (!vis[i]) {
ans++;
bfs(i);
}
cout << ans;
return ;
}
int32_t main() {
/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */
//int t;cin>>t;while(t--)
solve();
return 0;
}
|
#pragma once
#include <iostream>
#include <sstream>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <string.h>
#include <windows.h>
#include <fstream>
#include <iomanip>
#include <ctime>
using namespace std;
#define Enter 13
#define ESC 27
#define Back 8
#define Up 72
#define Down 80
#define Left 75
#define Right 77
#define Num1 49
#define Num2 50
#define nameMAX 38
#define numMAX 10
//==========Khai bao ham
string NhapChuoi(int x, int y, string str);
int NhapSo(int x, int y, int num);
int toInt(string a);
string toString(int number);
void gotoxy(short x,short y);
string NhapTenSach(int x, int y, string str);
int NhapMaSach(int x, int y, int num);
string NhapViTri(int x, int y, string str);
//===============Nhap chuoi VI TRI ======// co 2 ki tu gom 1 chu 1 so
string NhapViTri(int x, int y, string str)
{
int vitri = str.length();
char* c = new char[str.size() + 1];
strcpy(c,str.c_str());
int chr;
do
{
gotoxy(x + vitri, y);
fflush(stdin);
chr = getch();
if (chr == Enter && vitri == 5)
{
c[2]= '\0';
str=c;
delete[] c;
return str;
}
else if (chr == Back && vitri > 0)
{
if(vitri==4)
{
vitri -= 4;
c[0] = '\0';
gotoxy(x+vitri,y); cout << " ";
gotoxy(x+vitri,y);
}
else if(vitri==5)
{
vitri--;
c[1] = '\0';
gotoxy(x+vitri,y); cout << " ";
gotoxy(x+vitri,y);
}
// vitri--;
// c[vitri]= '\0';
// gotoxy(x + vitri, y); cout << " ";
// if(vitri==4) vitri -= 3;
// gotoxy(x + vitri, y);
}
else if (((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z')) && vitri == 0)
{
c[0] = char(toupper(chr));
cout << c[0];
vitri += 4;
}
else if( chr >= '0' && chr <= '9' && vitri==4 )
{
c[1] = chr;
cout << c[1];
vitri++;
}
} while (chr != ESC);
delete[] c;
return str;
}
//=======Nhap masach (DMS): nhap 0-9, co 1->3 chu so, khong nhan '0' dau tien=========//
int NhapMaSach(int x, int y, int num)
{
//tien xu li
string str= toString(num);
int vitri = str.length();
char* c = new char[str.size() + 1];
strcpy(c,str.c_str());
gotoxy(x,y); cout << num;
int chr;
do
{
gotoxy(x+vitri,y); chr= getch();
if (chr == Enter && vitri != 0)
{
// while(c[0]== ' ') for(int i=0; i<vitri; i++) c[i]=c[i+1];
// while(c[vitri-1]== ' ') c[vitri-1]= '\0';
c[2]= '\0';
str=c;
delete[] c;
num= toInt(str);
return num;
}
else if (chr == Back && vitri > 0)
{
vitri--;
c[vitri]= '\0';
gotoxy(x + vitri, y); cout << " ";
gotoxy(x + vitri, y);
}
else if(chr >= '0' && chr <= '9' && vitri<3)
{
if(chr == '0' && vitri==0) continue;
c[vitri]= char(chr);
cout << c[vitri];
vitri++;
}
} while(chr != ESC);
delete[] c;
return -1;
}
//===Nhap ten sach: A-Za-z0-9 + viet hoa chu cai dau + loc khoang trang thua
string NhapTenSach(int x, int y, string str)
{
int vitri = str.length();
char* c = new char[str.size() + 1];
strcpy(c,str.c_str());
//gotoxy(x,y); cout << c;
int chr;
do
{
gotoxy(x + vitri, y);
fflush(stdin);
chr = getch();
if (chr == Enter && vitri != 0)
{
//while(c[0]== ' ') for(int i=0; i<vitri; i++) c[i]=c[i+1];
if(c[vitri-1]== ' ') c[vitri-1]= '\0';
c[vitri]= '\0';
str=c;
// delete[] c;
return str;
}
else if (chr == Back && vitri > 0)
{
vitri--;
c[vitri]= '\0';
gotoxy(x + vitri, y); cout << " ";
gotoxy(x + vitri, y);
}
else if (((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z') || chr == ' ' || (chr>='0' && chr<='9')) && vitri < nameMAX)
{
if ( chr== ' ' && ( vitri==0 || c[vitri - 1]==' ')) continue;
if ( vitri==0 || c[vitri - 1]==' ') c[vitri] = char(toupper(chr));
else c[vitri] = char(tolower(chr));
cout << c[vitri];
vitri++;
}
} while (chr != ESC);
delete[] c;
return str;
}
//===Nhap chuoi: A-Za-z + viet hoa chu cai dau + loc khoang trang thua
string NhapChuoi(int x, int y, string str)
{
int vitri = str.length();
char* c = new char[str.size() + 1];
strcpy(c,str.c_str());
//gotoxy(x,y); cout << c;
int chr;
do
{
gotoxy(x + vitri, y);
fflush(stdin);
chr = getch();
if (chr == Enter && vitri != 0)
{
//while(c[0]== ' ') for(int i=0; i<vitri; i++) c[i]=c[i+1];
if(c[vitri-1]== ' ') c[vitri-1]= '\0';
c[vitri]= '\0';
str=c;
// delete[] c;
return str;
}
else if (chr == Back && vitri > 0)
{
vitri--;
c[vitri]= '\0';
gotoxy(x + vitri, y); cout << " ";
gotoxy(x + vitri, y);
}
else if (((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z') || chr == ' ') && vitri < nameMAX)
{
if ( chr== ' ' && ( vitri==0 || c[vitri - 1]==' ')) continue;
if ( vitri==0 || c[vitri - 1]==' ') c[vitri] = char(toupper(chr));
else c[vitri] = char(tolower(chr));
cout << c[vitri];
vitri++;
}
} while (chr != ESC);
delete[] c;
return "";
}
//=======Nhap so: 0-9=========
int NhapSo(int x, int y, int num)
{
//tien xu li
// string str= toString(num);
string str= "";
int vitri = str.length();
char* c = new char[str.size() + 1];
strcpy(c,str.c_str());
// gotoxy(x,y); cout << num;
// Sleep(1999);
// gotoxy(x,y); cout << str;
// Sleep(1999);
// gotoxy(x,y); cout << c;
int chr;
do
{
gotoxy(x+vitri,y);
fflush(stdin); chr= getch();
if (chr == Enter && vitri != 0)
{
//while(c[0]== ' ') for(int i=0; i<vitri; i++) c[i]=c[i+1];
c[vitri]= '\0';
//while(c[vitri-1]== ' ') c[vitri-1]= '\0';
str=c;
// delete[] c;
num= toInt(str);
return num;
}
else if (chr == Back && vitri > 0)
{
vitri--;
c[vitri]= '\0';
gotoxy(x + vitri, y); cout << " ";
gotoxy(x + vitri, y);
}
else if(chr >= '0' && chr <= '9')
{
if(chr == '0' && vitri==0) continue;
c[vitri]= chr;
cout << c[vitri];
vitri++;
}
} while(chr != ESC);
delete[] c;
return num;
}
//=======Nhap nam: <=2021=========
int NhapNam(int x, int y, int num)
{
//tien xu li
// string str= toString(num);
string str= "";
int vitri = str.length();
char* c = new char[str.size() + 1];
strcpy(c,str.c_str());
// gotoxy(x,y); cout << num;
// Sleep(1999);
// gotoxy(x,y); cout << str;
// Sleep(1999);
// gotoxy(x,y); cout << c;
int chr;
do
{
gotoxy(x+vitri,y);
fflush(stdin); chr= getch();
if (chr == Enter && vitri != 0)
{
//while(c[0]== ' ') for(int i=0; i<vitri; i++) c[i]=c[i+1];
c[vitri]= '\0';
//while(c[vitri-1]== ' ') c[vitri-1]= '\0';
str=c;
// delete[] c;
num= toInt(str);
if(num>2021)
{
gotoxy(x,y); cout << "Hu cau!";
Sleep(500);
gotoxy(x,y); cout << "Nhap lai!";
Sleep(500);
gotoxy(x,y); cout << " ";
num= NhapNam(x,y,num);
}
return num;
}
else if (chr == Back && vitri > 0)
{
vitri--;
c[vitri]= '\0';
gotoxy(x + vitri, y); cout << " ";
gotoxy(x + vitri, y);
}
else if(chr >= '0' && chr <= '9' && vitri < 4)
{
c[vitri]= char(chr);
cout << c[vitri];
vitri++;
}
} while(chr != ESC);
delete[] c;
return num;
}
//=======String to Int
int toInt(string a)
{
int tong = 0;
for (int i = 0; i < a.length(); i++)
{
tong *= 10;
tong += (int)(a[i] - '0');
}
return tong;
}
//========Int to String
string toString(int number)
{
string result;
ostringstream convert;
convert << number;
result = convert.str();
return result;
}
//===============Nhap chuoi in hoa: A-Z (ma ISBN) ======= //
string NhapChuoiHoa(int x, int y, string str)
{
int vitri = str.length();
char* c = new char[str.size() + 1];
strcpy(c,str.c_str());
// gotoxy(x,y); cout << c;
int chr;
do
{
gotoxy(x + vitri, y);
// fflush(stdin);
chr = getch();
if (chr == Enter && vitri == 4) //ma ISBN co 4 ki tu
{
//while(c[0]== ' ') for(int i=0; i<vitri; i++) c[i]=c[i+1];
//while(c[vitri-1]== ' ') c[vitri-1]= '\0';
c[vitri]= '\0';
str=c;
// delete[] c;
return str;
}
else if (chr == Back && vitri > 0)
{
vitri--;
c[vitri]= '\0';
gotoxy(x + vitri, y); cout << " ";
gotoxy(x + vitri, y);
}
else if (((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z')) && vitri < 4)
{
c[vitri] = char(toupper(chr));
cout << c[vitri];
vitri++;
}
} while (chr != ESC);
// delete[] c;
return "";
}
//=========XOA DU LIEU FILE CU TRUOC KHI GHI===========
void clearFileContent(const char *filePath) {
FILE *f = fopen(filePath, "w");
if (f == NULL) {
printf("Can not open file %s to erase data.\n", filePath);
return;
}
fclose(f);
}
//========== TIM CHUOI TRONG CHUOI ==============//
int TimChuoiCon(string a, string b) //Tim a trong b
{
int asize= a.length();
int bsize= b.length();
if(asize>bsize) return 0;
char* tempa = new char[a.size() + 1];
strcpy(tempa,a.c_str());
char* tempb = new char[b.size() + 1];
strcpy(tempb,b.c_str());
if(asize==bsize)
{
if(strcmp(tempa,tempb)==0)
{
delete tempa;
delete tempb;
return 1;
}
else
{
delete tempa;
delete tempb;
return 0;
}
}
bool flag;
for(int i=0; i<=bsize-asize; i++)
{
flag=true;
for(int j=0; j<asize; j++)
{
if(a[j] != b[j+i])
{
flag= false;
break;
}
}
if(flag)
{
delete tempa;
delete tempb;
return 1;
}
}
delete tempa;
delete tempb;
return 0;
}
//Di den (x,y)
void gotoxy(short x,short y)
{
HANDLE hConsoleOutput;
COORD Cursor_an_Pos = { x,y};
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput , Cursor_an_Pos);
}
//An/Hien con tro
void ShowCur(bool CursorVisibility)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor = { 1, CursorVisibility };
SetConsoleCursorInfo(handle, &cursor);
}
int wherex( void )
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
return screen_buffer_info.dwCursorPosition.X;
}
int wherey( void )
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
return screen_buffer_info.dwCursorPosition.Y;
}
void clreol( ) {
COORD coord;
DWORD written;
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
coord.X = info.dwCursorPosition.X;
coord.Y = info.dwCursorPosition.Y;
FillConsoleOutputCharacter (GetStdHandle(STD_OUTPUT_HANDLE), ' ',
info.dwSize.X - info.dwCursorPosition.X * info.dwCursorPosition.Y, coord, &written);
gotoxy (info.dwCursorPosition.X , info.dwCursorPosition.Y );
}
void SetColor(WORD color)
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
WORD wAttributes = screen_buffer_info.wAttributes;
color &= 0x000f;
wAttributes &= 0xfff0;
wAttributes |= color;
SetConsoleTextAttribute(hConsoleOutput, wAttributes);
}
void SetBGColor(WORD color)
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
WORD wAttributes = screen_buffer_info.wAttributes;
color &= 0x000f;
color <<= 4;
wAttributes &= 0xff0f;
wAttributes |= color;
SetConsoleTextAttribute(hConsoleOutput, wAttributes);
}
void clrscr() {
system("cls");
}
//==== Doi console tittle ====//
BOOL WINAPI SetConsoleTitle(
_In_ LPCTSTR lpConsoleTitle
);
//======================//
//void SetWindowSize(SHORT width, SHORT height)
//{
// HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
//
// SMALL_RECT WindowSize;
// WindowSize.Top = 0;
// WindowSize.Left = 0;
// WindowSize.Right = width;
// WindowSize.Bottom = height;
//
// SetConsoleWindowInfo(hStdout, 1, &WindowSize);
//}
void resizeConsole(int width, int height)
{
HWND console = GetConsoleWindow();
RECT r;
GetWindowRect(console, &r);
MoveWindow(console, r.left, r.top, width, height, TRUE);
}
/*char* Pwd () {
char S[40]; int i=0;
while ((S[i]= getch()) != Enter )
{ printf ("%c", '*') ; i++ ;
}
S[i]='\0';
return S;
}
int CheckPwd () {
int dem =0;
for ( dem =1 ; dem <=3 ; dem++)
{ printf( "Password :");
if (strcmp(Pwd(),PASSWORD) ==0) return 1;
else printf ( "\nPassword sai. Hay nhap lai\n") ;
}
return 0;
}*/
|
#include "sudoku.h"
#include "depth_first_search.h"
int main(int argc, char ** argv)
{
sudoku* s;
depth_first_search* dfs;
for (int i = 0; i < 10; i++)
{
s = new sudoku();
dfs = new depth_first_search();
dfs->init(s);
delete s;
dfs->execute(true);
delete dfs;
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3+3;
int d[maxn];
typedef long long ll;
int main(){
int n,m;
scanf("%d",&n);
ll sum = 0;
for(int i=1;i<=n;++i){
int a,b;
scanf("%d%d",&m,&a);
for(int i=1;i<m;++i){
scanf("%d",&b);
if(b<0)a+=b;
if(b>0&&b<a){
a = b;
d[a]=1;
}
}
sum+=a;
}
int ans=0,bns=0;
for(int i=1;i<=n;++i){
if(d[i])ans++;
if(i==1&&d[i]&&d[i+1]&&d[n])bns++;
else if(i==n&&d[i]&&d[i-1]&&d[1])bns++;
else if(i>1&&i<n&&d[i]&&d[i-1]&&d[i+1])bns++;
}
printf("%lld %d %d\n",sum,ans,bns);
}
|
#pragma once
#ifndef TCylinder_H
#define TCylinder_H
#include "mesh.h"
namespace T3D
{
class TCylinder :
public Mesh
{
public:
TCylinder(float radius, float height, int density);
virtual ~TCylinder (void);
};
}
#endif
|
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2016, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
/*
Implementation of padding layer, which adds paddings to input blob.
*/
#include "../precomp.hpp"
#include "op_halide.hpp"
#include <vector>
namespace cv
{
namespace dnn
{
class PaddingLayerImpl : public PaddingLayer
{
public:
PaddingLayerImpl(const LayerParams ¶ms)
{
setParamsFrom(params);
paddingDim = params.get<int>("padding_dim");
padding = params.get<int>("padding");
inputDims = params.get<int>("input_dims", 0);
index = params.get<int>("index", 0);
paddingValue = params.get<double>("value", 0);
if(paddingDim < 0 || padding < 0)
CV_Error(cv::Error::StsNotImplemented, "Negative padding and dim aren't supported");
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
const int requiredOutputs,
std::vector<MatShape> &outputs,
std::vector<MatShape> &internals) const
{
outputs.clear();
for(int i = 0; i < inputs.size(); i++)
{
MatShape shape = inputs[i];
int dim = getPadDim(shape);
CV_Assert(dim < shape.size());
shape[dim] += padding;
outputs.push_back(shape);
}
return false;
}
virtual bool supportBackend(int backendId)
{
return backendId == DNN_BACKEND_DEFAULT ||
backendId == DNN_BACKEND_HALIDE && haveHalide();
}
void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
{
CV_TRACE_FUNCTION();
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
for(int i = 0; i < inputs.size(); i++)
{
outputs[i] = paddingValue;
const Mat& inp = *inputs[i];
Mat& out = outputs[i];
int dims = inp.dims;
MatShape inShape(inp.size.p, inp.size.p + dims);
MatShape outShape(out.size.p, out.size.p + dims);
int dim = getPadDim(inShape);
int actualIndex = index;
if(index == 0)
actualIndex = inShape[dim];
std::vector<std::pair<Range, Range> > srcDstRanges;
srcDstRanges.push_back(std::make_pair(Range(0, actualIndex), Range(0, actualIndex)));
srcDstRanges.push_back(std::make_pair(Range(actualIndex, inShape[dim]),
Range(actualIndex + padding, outShape[dim])));
std::vector<Range> srcRanges(dims, Range::all()), dstRanges = srcRanges;
for(int j = 0; j < srcDstRanges.size(); j++)
{
if(!srcDstRanges[j].first.empty())
{
srcRanges[dim] = srcDstRanges[j].first;
dstRanges[dim] = srcDstRanges[j].second;
Mat dst = out(&dstRanges[0]);
Mat src = inp(&srcRanges[0]).clone();
src.copyTo(dst);
}
}
}
}
int getPadDim(const MatShape& shape) const
{
return inputDims > 0 && (int)shape.size() > inputDims ? paddingDim + 1 : paddingDim;
}
virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
{
#ifdef HAVE_HALIDE
int inW, inH, inC, inN;
Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
getCanonicalSize(inputBuffer, &inW, &inH, &inC, &inN);
Halide::Var x("x"), y("y"), c("c"), n("n");
Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
Halide::Func padded =
Halide::BoundaryConditions::constant_exterior(inputBuffer, paddingValue);
top(x, y, c, n) = padded(x, y, c, n);
return Ptr<BackendNode>(new HalideBackendNode(top));
#endif // HAVE_HALIDE
return Ptr<BackendNode>();
}
int paddingDim, padding, inputDims, index;
float paddingValue;
};
Ptr<PaddingLayer> PaddingLayer::create(const LayerParams ¶ms)
{
return Ptr<PaddingLayer>(new PaddingLayerImpl(params));
}
}
}
|
#ifndef __VIVADO_SYNTH__
#include <fstream>
using namespace std;
// Debug utility
ofstream* global_debug_handle;
#endif //__VIVADO_SYNTH__
#include "sblr30_4_opt_compute_units.h"
#include "hw_classes.h"
struct img_img_update_0_write0_merged_banks_12_cache {
// RAM Box: {[-4, 1920], [-1, 1080]}
// Capacity: 966
// # of read delays: 6
hw_uint<16> f0;
hw_uint<16> f2;
fifo<hw_uint<16>, 480> f3;
hw_uint<16> f4;
hw_uint<16> f6;
fifo<hw_uint<16>, 480> f7;
hw_uint<16> f8;
hw_uint<16> f10;
inline hw_uint<16> peek_0() {
return f0;
}
inline hw_uint<16> peek_1() {
return f2;
}
inline hw_uint<16> peek_481() {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f3.back();
}
inline hw_uint<16> peek_482() {
return f4;
}
inline hw_uint<16> peek_483() {
return f6;
}
inline hw_uint<16> peek_963() {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f7.back();
}
inline hw_uint<16> peek_964() {
return f8;
}
inline hw_uint<16> peek_965() {
return f10;
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f10 = f8;
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 480
f8 = f7.back();
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 480 reading from capacity: 1
f7.push(f6);
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f6 = f4;
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 480
f4 = f3.back();
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 480 reading from capacity: 1
f3.push(f2);
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f2 = f0;
// cap: 1
f0 = value;
}
};
struct img_img_update_0_write1_merged_banks_12_cache {
// RAM Box: {[-3, 1921], [-1, 1080]}
// Capacity: 966
// # of read delays: 4
hw_uint<16> f0;
hw_uint<16> f2;
fifo<hw_uint<16>, 481> f3;
hw_uint<16> f4;
fifo<hw_uint<16>, 481> f5;
hw_uint<16> f6;
inline hw_uint<16> peek_0() {
return f0;
}
inline hw_uint<16> peek_1() {
return f2;
}
inline hw_uint<16> peek_482() {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f3.back();
}
inline hw_uint<16> peek_483() {
return f4;
}
inline hw_uint<16> peek_964() {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f5.back();
}
inline hw_uint<16> peek_965() {
return f6;
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 481
f6 = f5.back();
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 481 reading from capacity: 1
f5.push(f4);
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 481
f4 = f3.back();
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 481 reading from capacity: 1
f3.push(f2);
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f2 = f0;
// cap: 1
f0 = value;
}
};
struct img_img_update_0_write2_merged_banks_12_cache {
// RAM Box: {[-2, 1922], [-1, 1080]}
// Capacity: 966
// # of read delays: 4
hw_uint<16> f0;
hw_uint<16> f2;
fifo<hw_uint<16>, 481> f3;
hw_uint<16> f4;
fifo<hw_uint<16>, 481> f5;
hw_uint<16> f6;
inline hw_uint<16> peek_0() {
return f0;
}
inline hw_uint<16> peek_1() {
return f2;
}
inline hw_uint<16> peek_482() {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f3.back();
}
inline hw_uint<16> peek_483() {
return f4;
}
inline hw_uint<16> peek_964() {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f5.back();
}
inline hw_uint<16> peek_965() {
return f6;
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 481
f6 = f5.back();
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 481 reading from capacity: 1
f5.push(f4);
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 481
f4 = f3.back();
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 481 reading from capacity: 1
f3.push(f2);
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f2 = f0;
// cap: 1
f0 = value;
}
};
struct img_img_update_0_write3_merged_banks_12_cache {
// RAM Box: {[-1, 1923], [-1, 1080]}
// Capacity: 967
// # of read delays: 7
hw_uint<16> f0;
hw_uint<16> f2;
hw_uint<16> f4;
fifo<hw_uint<16>, 480> f5;
hw_uint<16> f6;
hw_uint<16> f8;
fifo<hw_uint<16>, 480> f9;
hw_uint<16> f10;
hw_uint<16> f12;
inline hw_uint<16> peek_0() {
return f0;
}
inline hw_uint<16> peek_1() {
return f2;
}
inline hw_uint<16> peek_2() {
return f4;
}
inline hw_uint<16> peek_482() {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f5.back();
}
inline hw_uint<16> peek_483() {
return f6;
}
inline hw_uint<16> peek_484() {
return f8;
}
inline hw_uint<16> peek_964() {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f9.back();
}
inline hw_uint<16> peek_965() {
return f10;
}
inline hw_uint<16> peek_966() {
return f12;
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f12 = f10;
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 480
f10 = f9.back();
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 480 reading from capacity: 1
f9.push(f8);
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f8 = f6;
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 480
f6 = f5.back();
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 480 reading from capacity: 1
f5.push(f4);
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f4 = f2;
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// cap: 1 reading from capacity: 1
f2 = f0;
// cap: 1
f0 = value;
}
};
struct img_cache {
img_img_update_0_write0_merged_banks_12_cache img_img_update_0_write0_merged_banks_12;
img_img_update_0_write1_merged_banks_12_cache img_img_update_0_write1_merged_banks_12;
img_img_update_0_write2_merged_banks_12_cache img_img_update_0_write2_merged_banks_12;
img_img_update_0_write3_merged_banks_12_cache img_img_update_0_write3_merged_banks_12;
};
inline void img_img_update_0_write0_write(hw_uint<16>& img_img_update_0_write0, img_cache& img, int d0, int d1) {
img.img_img_update_0_write0_merged_banks_12.push(img_img_update_0_write0);
}
inline void img_img_update_0_write1_write(hw_uint<16>& img_img_update_0_write1, img_cache& img, int d0, int d1) {
img.img_img_update_0_write1_merged_banks_12.push(img_img_update_0_write1);
}
inline void img_img_update_0_write2_write(hw_uint<16>& img_img_update_0_write2, img_cache& img, int d0, int d1) {
img.img_img_update_0_write2_merged_banks_12.push(img_img_update_0_write2);
}
inline void img_img_update_0_write3_write(hw_uint<16>& img_img_update_0_write3, img_cache& img, int d0, int d1) {
img.img_img_update_0_write3_merged_banks_12.push(img_img_update_0_write3);
}
inline hw_uint<16> mag_x_rd0_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd0 read pattern: { mag_x_update_0[d0, d1] -> img[-1 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 966 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_966();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd1_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd1 read pattern: { mag_x_update_0[d0, d1] -> img[-1 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 484 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_484();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd10_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd10 read pattern: { mag_x_update_0[d0, d1] -> img[2 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 483 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_483();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd11_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd11 read pattern: { mag_x_update_0[d0, d1] -> img[2 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_1();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd12_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd12 read pattern: { mag_x_update_0[d0, d1] -> img[1 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_965();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd13_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd13 read pattern: { mag_x_update_0[d0, d1] -> img[1 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 483 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_483();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd14_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd14 read pattern: { mag_x_update_0[d0, d1] -> img[1 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_1();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd15_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd15 read pattern: { mag_x_update_0[d0, d1] -> img[3 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_965();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd16_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd16 read pattern: { mag_x_update_0[d0, d1] -> img[3 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 483 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_483();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd17_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd17 read pattern: { mag_x_update_0[d0, d1] -> img[3 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_1();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd18_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd18 read pattern: { mag_x_update_0[d0, d1] -> img[2 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_965();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd19_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd19 read pattern: { mag_x_update_0[d0, d1] -> img[2 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 483 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_483();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd2_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd2 read pattern: { mag_x_update_0[d0, d1] -> img[-1 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 2 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_2();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd20_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd20 read pattern: { mag_x_update_0[d0, d1] -> img[2 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_1();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd21_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd21 read pattern: { mag_x_update_0[d0, d1] -> img[4 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 964 : 0 <= d0 <= 478 and 0 <= d1 <= 1079; mag_x_update_0[d0, d1] -> (485 + d0) : d0 = 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_964();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd22_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd22 read pattern: { mag_x_update_0[d0, d1] -> img[4 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 482 : 0 <= d0 <= 478 and 0 <= d1 <= 1079; mag_x_update_0[d0, d1] -> (3 + d0) : d0 = 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_482();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd23_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd23 read pattern: { mag_x_update_0[d0, d1] -> img[4 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_0();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd3_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd3 read pattern: { mag_x_update_0[d0, d1] -> img[1 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_965();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd4_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd4 read pattern: { mag_x_update_0[d0, d1] -> img[1 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 483 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_483();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd5_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd5 read pattern: { mag_x_update_0[d0, d1] -> img[1 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_1();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd6_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd6 read pattern: { mag_x_update_0[d0, d1] -> img[4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_965();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd7_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd7 read pattern: { mag_x_update_0[d0, d1] -> img[4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 483 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_483();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd8_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd8 read pattern: { mag_x_update_0[d0, d1] -> img[4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_1();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_x_rd9_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_x_rd9 read pattern: { mag_x_update_0[d0, d1] -> img[2 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_x_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_965();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd0_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd0 read pattern: { mag_y_update_0[d0, d1] -> img[-1 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 966 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_966();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd1_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd1 read pattern: { mag_y_update_0[d0, d1] -> img[-1 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 2 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_2();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd10_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd10 read pattern: { mag_y_update_0[d0, d1] -> img[2 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_965();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd11_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd11 read pattern: { mag_y_update_0[d0, d1] -> img[2 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_1();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd12_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd12 read pattern: { mag_y_update_0[d0, d1] -> img[1 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_965();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd13_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd13 read pattern: { mag_y_update_0[d0, d1] -> img[1 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_1();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd14_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd14 read pattern: { mag_y_update_0[d0, d1] -> img[2 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_965();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd15_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd15 read pattern: { mag_y_update_0[d0, d1] -> img[2 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_1();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd16_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd16 read pattern: { mag_y_update_0[d0, d1] -> img[3 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_965();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd17_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd17 read pattern: { mag_y_update_0[d0, d1] -> img[3 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_1();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd18_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd18 read pattern: { mag_y_update_0[d0, d1] -> img[2 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_965();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd19_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd19 read pattern: { mag_y_update_0[d0, d1] -> img[2 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write2 = img.img_img_update_0_write2_merged_banks_12.peek_1();
return value_img_img_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd2_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd2 read pattern: { mag_y_update_0[d0, d1] -> img[4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_965();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd20_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd20 read pattern: { mag_y_update_0[d0, d1] -> img[3 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_965();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd21_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd21 read pattern: { mag_y_update_0[d0, d1] -> img[3 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write3 = img.img_img_update_0_write3_merged_banks_12.peek_1();
return value_img_img_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd22_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd22 read pattern: { mag_y_update_0[d0, d1] -> img[4 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 964 : 0 <= d0 <= 478 and 0 <= d1 <= 1079; mag_y_update_0[d0, d1] -> (485 + d0) : d0 = 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_964();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd23_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd23 read pattern: { mag_y_update_0[d0, d1] -> img[4 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_0();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd3_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd3 read pattern: { mag_y_update_0[d0, d1] -> img[4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_1();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd4_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd4 read pattern: { mag_y_update_0[d0, d1] -> img[1 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_965();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd5_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd5 read pattern: { mag_y_update_0[d0, d1] -> img[1 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_1();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd6_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd6 read pattern: { mag_y_update_0[d0, d1] -> img[4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_965();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd7_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd7 read pattern: { mag_y_update_0[d0, d1] -> img[4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write0 = img.img_img_update_0_write0_merged_banks_12.peek_1();
return value_img_img_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd8_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd8 read pattern: { mag_y_update_0[d0, d1] -> img[1 + 4d0, -1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 965 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_965();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> mag_y_rd9_select(img_cache& img, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// mag_y_rd9 read pattern: { mag_y_update_0[d0, d1] -> img[1 + 4d0, 1 + d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { img_update_0[d0, d1] -> [d1, d0, 1] : -1 <= d0 <= 480 and -1 <= d1 <= 1080 }
// DD fold: { mag_y_update_0[d0, d1] -> 1 : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
auto value_img_img_update_0_write1 = img.img_img_update_0_write1_merged_banks_12.peek_1();
return value_img_img_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
// # of bundles = 3
// img_update_0_write
// img_img_update_0_write0
// img_img_update_0_write1
// img_img_update_0_write2
// img_img_update_0_write3
inline void img_img_update_0_write_bundle_write(hw_uint<64>& img_update_0_write, img_cache& img, int d0, int d1) {
hw_uint<16> img_img_update_0_write0_res = img_update_0_write.extract<0, 15>();
img_img_update_0_write0_write(img_img_update_0_write0_res, img, d0, d1);
hw_uint<16> img_img_update_0_write1_res = img_update_0_write.extract<16, 31>();
img_img_update_0_write1_write(img_img_update_0_write1_res, img, d0, d1);
hw_uint<16> img_img_update_0_write2_res = img_update_0_write.extract<32, 47>();
img_img_update_0_write2_write(img_img_update_0_write2_res, img, d0, d1);
hw_uint<16> img_img_update_0_write3_res = img_update_0_write.extract<48, 63>();
img_img_update_0_write3_write(img_img_update_0_write3_res, img, d0, d1);
}
// mag_x_update_0_read
// mag_x_rd0
// mag_x_rd1
// mag_x_rd2
// mag_x_rd3
// mag_x_rd4
// mag_x_rd5
// mag_x_rd6
// mag_x_rd7
// mag_x_rd8
// mag_x_rd9
// mag_x_rd10
// mag_x_rd11
// mag_x_rd12
// mag_x_rd13
// mag_x_rd14
// mag_x_rd15
// mag_x_rd16
// mag_x_rd17
// mag_x_rd18
// mag_x_rd19
// mag_x_rd20
// mag_x_rd21
// mag_x_rd22
// mag_x_rd23
inline hw_uint<384> img_mag_x_update_0_read_bundle_read(img_cache& img, int d0, int d1) {
// # of ports in bundle: 24
// mag_x_rd0
// mag_x_rd1
// mag_x_rd2
// mag_x_rd3
// mag_x_rd4
// mag_x_rd5
// mag_x_rd6
// mag_x_rd7
// mag_x_rd8
// mag_x_rd9
// mag_x_rd10
// mag_x_rd11
// mag_x_rd12
// mag_x_rd13
// mag_x_rd14
// mag_x_rd15
// mag_x_rd16
// mag_x_rd17
// mag_x_rd18
// mag_x_rd19
// mag_x_rd20
// mag_x_rd21
// mag_x_rd22
// mag_x_rd23
hw_uint<384> result;
hw_uint<16> mag_x_rd0_res = mag_x_rd0_select(img, d0, d1);
set_at<0, 384>(result, mag_x_rd0_res);
hw_uint<16> mag_x_rd1_res = mag_x_rd1_select(img, d0, d1);
set_at<16, 384>(result, mag_x_rd1_res);
hw_uint<16> mag_x_rd2_res = mag_x_rd2_select(img, d0, d1);
set_at<32, 384>(result, mag_x_rd2_res);
hw_uint<16> mag_x_rd3_res = mag_x_rd3_select(img, d0, d1);
set_at<48, 384>(result, mag_x_rd3_res);
hw_uint<16> mag_x_rd4_res = mag_x_rd4_select(img, d0, d1);
set_at<64, 384>(result, mag_x_rd4_res);
hw_uint<16> mag_x_rd5_res = mag_x_rd5_select(img, d0, d1);
set_at<80, 384>(result, mag_x_rd5_res);
hw_uint<16> mag_x_rd6_res = mag_x_rd6_select(img, d0, d1);
set_at<96, 384>(result, mag_x_rd6_res);
hw_uint<16> mag_x_rd7_res = mag_x_rd7_select(img, d0, d1);
set_at<112, 384>(result, mag_x_rd7_res);
hw_uint<16> mag_x_rd8_res = mag_x_rd8_select(img, d0, d1);
set_at<128, 384>(result, mag_x_rd8_res);
hw_uint<16> mag_x_rd9_res = mag_x_rd9_select(img, d0, d1);
set_at<144, 384>(result, mag_x_rd9_res);
hw_uint<16> mag_x_rd10_res = mag_x_rd10_select(img, d0, d1);
set_at<160, 384>(result, mag_x_rd10_res);
hw_uint<16> mag_x_rd11_res = mag_x_rd11_select(img, d0, d1);
set_at<176, 384>(result, mag_x_rd11_res);
hw_uint<16> mag_x_rd12_res = mag_x_rd12_select(img, d0, d1);
set_at<192, 384>(result, mag_x_rd12_res);
hw_uint<16> mag_x_rd13_res = mag_x_rd13_select(img, d0, d1);
set_at<208, 384>(result, mag_x_rd13_res);
hw_uint<16> mag_x_rd14_res = mag_x_rd14_select(img, d0, d1);
set_at<224, 384>(result, mag_x_rd14_res);
hw_uint<16> mag_x_rd15_res = mag_x_rd15_select(img, d0, d1);
set_at<240, 384>(result, mag_x_rd15_res);
hw_uint<16> mag_x_rd16_res = mag_x_rd16_select(img, d0, d1);
set_at<256, 384>(result, mag_x_rd16_res);
hw_uint<16> mag_x_rd17_res = mag_x_rd17_select(img, d0, d1);
set_at<272, 384>(result, mag_x_rd17_res);
hw_uint<16> mag_x_rd18_res = mag_x_rd18_select(img, d0, d1);
set_at<288, 384>(result, mag_x_rd18_res);
hw_uint<16> mag_x_rd19_res = mag_x_rd19_select(img, d0, d1);
set_at<304, 384>(result, mag_x_rd19_res);
hw_uint<16> mag_x_rd20_res = mag_x_rd20_select(img, d0, d1);
set_at<320, 384>(result, mag_x_rd20_res);
hw_uint<16> mag_x_rd21_res = mag_x_rd21_select(img, d0, d1);
set_at<336, 384>(result, mag_x_rd21_res);
hw_uint<16> mag_x_rd22_res = mag_x_rd22_select(img, d0, d1);
set_at<352, 384>(result, mag_x_rd22_res);
hw_uint<16> mag_x_rd23_res = mag_x_rd23_select(img, d0, d1);
set_at<368, 384>(result, mag_x_rd23_res);
return result;
}
// mag_y_update_0_read
// mag_y_rd0
// mag_y_rd1
// mag_y_rd2
// mag_y_rd3
// mag_y_rd4
// mag_y_rd5
// mag_y_rd6
// mag_y_rd7
// mag_y_rd8
// mag_y_rd9
// mag_y_rd10
// mag_y_rd11
// mag_y_rd12
// mag_y_rd13
// mag_y_rd14
// mag_y_rd15
// mag_y_rd16
// mag_y_rd17
// mag_y_rd18
// mag_y_rd19
// mag_y_rd20
// mag_y_rd21
// mag_y_rd22
// mag_y_rd23
inline hw_uint<384> img_mag_y_update_0_read_bundle_read(img_cache& img, int d0, int d1) {
// # of ports in bundle: 24
// mag_y_rd0
// mag_y_rd1
// mag_y_rd2
// mag_y_rd3
// mag_y_rd4
// mag_y_rd5
// mag_y_rd6
// mag_y_rd7
// mag_y_rd8
// mag_y_rd9
// mag_y_rd10
// mag_y_rd11
// mag_y_rd12
// mag_y_rd13
// mag_y_rd14
// mag_y_rd15
// mag_y_rd16
// mag_y_rd17
// mag_y_rd18
// mag_y_rd19
// mag_y_rd20
// mag_y_rd21
// mag_y_rd22
// mag_y_rd23
hw_uint<384> result;
hw_uint<16> mag_y_rd0_res = mag_y_rd0_select(img, d0, d1);
set_at<0, 384>(result, mag_y_rd0_res);
hw_uint<16> mag_y_rd1_res = mag_y_rd1_select(img, d0, d1);
set_at<16, 384>(result, mag_y_rd1_res);
hw_uint<16> mag_y_rd2_res = mag_y_rd2_select(img, d0, d1);
set_at<32, 384>(result, mag_y_rd2_res);
hw_uint<16> mag_y_rd3_res = mag_y_rd3_select(img, d0, d1);
set_at<48, 384>(result, mag_y_rd3_res);
hw_uint<16> mag_y_rd4_res = mag_y_rd4_select(img, d0, d1);
set_at<64, 384>(result, mag_y_rd4_res);
hw_uint<16> mag_y_rd5_res = mag_y_rd5_select(img, d0, d1);
set_at<80, 384>(result, mag_y_rd5_res);
hw_uint<16> mag_y_rd6_res = mag_y_rd6_select(img, d0, d1);
set_at<96, 384>(result, mag_y_rd6_res);
hw_uint<16> mag_y_rd7_res = mag_y_rd7_select(img, d0, d1);
set_at<112, 384>(result, mag_y_rd7_res);
hw_uint<16> mag_y_rd8_res = mag_y_rd8_select(img, d0, d1);
set_at<128, 384>(result, mag_y_rd8_res);
hw_uint<16> mag_y_rd9_res = mag_y_rd9_select(img, d0, d1);
set_at<144, 384>(result, mag_y_rd9_res);
hw_uint<16> mag_y_rd10_res = mag_y_rd10_select(img, d0, d1);
set_at<160, 384>(result, mag_y_rd10_res);
hw_uint<16> mag_y_rd11_res = mag_y_rd11_select(img, d0, d1);
set_at<176, 384>(result, mag_y_rd11_res);
hw_uint<16> mag_y_rd12_res = mag_y_rd12_select(img, d0, d1);
set_at<192, 384>(result, mag_y_rd12_res);
hw_uint<16> mag_y_rd13_res = mag_y_rd13_select(img, d0, d1);
set_at<208, 384>(result, mag_y_rd13_res);
hw_uint<16> mag_y_rd14_res = mag_y_rd14_select(img, d0, d1);
set_at<224, 384>(result, mag_y_rd14_res);
hw_uint<16> mag_y_rd15_res = mag_y_rd15_select(img, d0, d1);
set_at<240, 384>(result, mag_y_rd15_res);
hw_uint<16> mag_y_rd16_res = mag_y_rd16_select(img, d0, d1);
set_at<256, 384>(result, mag_y_rd16_res);
hw_uint<16> mag_y_rd17_res = mag_y_rd17_select(img, d0, d1);
set_at<272, 384>(result, mag_y_rd17_res);
hw_uint<16> mag_y_rd18_res = mag_y_rd18_select(img, d0, d1);
set_at<288, 384>(result, mag_y_rd18_res);
hw_uint<16> mag_y_rd19_res = mag_y_rd19_select(img, d0, d1);
set_at<304, 384>(result, mag_y_rd19_res);
hw_uint<16> mag_y_rd20_res = mag_y_rd20_select(img, d0, d1);
set_at<320, 384>(result, mag_y_rd20_res);
hw_uint<16> mag_y_rd21_res = mag_y_rd21_select(img, d0, d1);
set_at<336, 384>(result, mag_y_rd21_res);
hw_uint<16> mag_y_rd22_res = mag_y_rd22_select(img, d0, d1);
set_at<352, 384>(result, mag_y_rd22_res);
hw_uint<16> mag_y_rd23_res = mag_y_rd23_select(img, d0, d1);
set_at<368, 384>(result, mag_y_rd23_res);
return result;
}
#include "hw_classes.h"
struct mag_x_mag_x_update_0_write0_merged_banks_1_cache {
// RAM Box: {[0, 1916], [0, 1079]}
// Capacity: 1
// # of read delays: 1
fifo<hw_uint<16>, 1> f;
inline hw_uint<16> peek(const int offset) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.peek(0 - offset);
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.push(value);
}
};
struct mag_x_mag_x_update_0_write1_merged_banks_1_cache {
// RAM Box: {[1, 1917], [0, 1079]}
// Capacity: 1
// # of read delays: 1
fifo<hw_uint<16>, 1> f;
inline hw_uint<16> peek(const int offset) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.peek(0 - offset);
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.push(value);
}
};
struct mag_x_mag_x_update_0_write2_merged_banks_1_cache {
// RAM Box: {[2, 1918], [0, 1079]}
// Capacity: 1
// # of read delays: 1
fifo<hw_uint<16>, 1> f;
inline hw_uint<16> peek(const int offset) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.peek(0 - offset);
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.push(value);
}
};
struct mag_x_mag_x_update_0_write3_merged_banks_1_cache {
// RAM Box: {[3, 1919], [0, 1079]}
// Capacity: 1
// # of read delays: 1
fifo<hw_uint<16>, 1> f;
inline hw_uint<16> peek(const int offset) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.peek(0 - offset);
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.push(value);
}
};
struct mag_x_cache {
mag_x_mag_x_update_0_write0_merged_banks_1_cache mag_x_mag_x_update_0_write0_merged_banks_1;
mag_x_mag_x_update_0_write1_merged_banks_1_cache mag_x_mag_x_update_0_write1_merged_banks_1;
mag_x_mag_x_update_0_write2_merged_banks_1_cache mag_x_mag_x_update_0_write2_merged_banks_1;
mag_x_mag_x_update_0_write3_merged_banks_1_cache mag_x_mag_x_update_0_write3_merged_banks_1;
};
inline void mag_x_mag_x_update_0_write0_write(hw_uint<16>& mag_x_mag_x_update_0_write0, mag_x_cache& mag_x, int d0, int d1) {
mag_x.mag_x_mag_x_update_0_write0_merged_banks_1.push(mag_x_mag_x_update_0_write0);
}
inline void mag_x_mag_x_update_0_write1_write(hw_uint<16>& mag_x_mag_x_update_0_write1, mag_x_cache& mag_x, int d0, int d1) {
mag_x.mag_x_mag_x_update_0_write1_merged_banks_1.push(mag_x_mag_x_update_0_write1);
}
inline void mag_x_mag_x_update_0_write2_write(hw_uint<16>& mag_x_mag_x_update_0_write2, mag_x_cache& mag_x, int d0, int d1) {
mag_x.mag_x_mag_x_update_0_write2_merged_banks_1.push(mag_x_mag_x_update_0_write2);
}
inline void mag_x_mag_x_update_0_write3_write(hw_uint<16>& mag_x_mag_x_update_0_write3, mag_x_cache& mag_x, int d0, int d1) {
mag_x.mag_x_mag_x_update_0_write3_merged_banks_1.push(mag_x_mag_x_update_0_write3);
}
inline hw_uint<16> sblr30_4_rd0_select(mag_x_cache& mag_x, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// sblr30_4_rd0 read pattern: { sblr30_4_update_0[d0, d1] -> mag_x[4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { sblr30_4_update_0[d0, d1] -> [1 + d1, 1 + d0, 4] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// DD fold: { }
auto value_mag_x_mag_x_update_0_write0 = mag_x.mag_x_mag_x_update_0_write0_merged_banks_1.peek(/* one reader or all rams */ 0);
return value_mag_x_mag_x_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> sblr30_4_rd1_select(mag_x_cache& mag_x, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// sblr30_4_rd1 read pattern: { sblr30_4_update_0[d0, d1] -> mag_x[1 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { sblr30_4_update_0[d0, d1] -> [1 + d1, 1 + d0, 4] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// DD fold: { }
auto value_mag_x_mag_x_update_0_write1 = mag_x.mag_x_mag_x_update_0_write1_merged_banks_1.peek(/* one reader or all rams */ 0);
return value_mag_x_mag_x_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> sblr30_4_rd2_select(mag_x_cache& mag_x, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// sblr30_4_rd2 read pattern: { sblr30_4_update_0[d0, d1] -> mag_x[2 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { sblr30_4_update_0[d0, d1] -> [1 + d1, 1 + d0, 4] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// DD fold: { }
auto value_mag_x_mag_x_update_0_write2 = mag_x.mag_x_mag_x_update_0_write2_merged_banks_1.peek(/* one reader or all rams */ 0);
return value_mag_x_mag_x_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> sblr30_4_rd3_select(mag_x_cache& mag_x, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// sblr30_4_rd3 read pattern: { sblr30_4_update_0[d0, d1] -> mag_x[3 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { sblr30_4_update_0[d0, d1] -> [1 + d1, 1 + d0, 4] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { mag_x_update_0[d0, d1] -> [1 + d1, 1 + d0, 3] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// DD fold: { }
auto value_mag_x_mag_x_update_0_write3 = mag_x.mag_x_mag_x_update_0_write3_merged_banks_1.peek(/* one reader or all rams */ 0);
return value_mag_x_mag_x_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
// # of bundles = 2
// mag_x_update_0_write
// mag_x_mag_x_update_0_write0
// mag_x_mag_x_update_0_write1
// mag_x_mag_x_update_0_write2
// mag_x_mag_x_update_0_write3
inline void mag_x_mag_x_update_0_write_bundle_write(hw_uint<64>& mag_x_update_0_write, mag_x_cache& mag_x, int d0, int d1) {
hw_uint<16> mag_x_mag_x_update_0_write0_res = mag_x_update_0_write.extract<0, 15>();
mag_x_mag_x_update_0_write0_write(mag_x_mag_x_update_0_write0_res, mag_x, d0, d1);
hw_uint<16> mag_x_mag_x_update_0_write1_res = mag_x_update_0_write.extract<16, 31>();
mag_x_mag_x_update_0_write1_write(mag_x_mag_x_update_0_write1_res, mag_x, d0, d1);
hw_uint<16> mag_x_mag_x_update_0_write2_res = mag_x_update_0_write.extract<32, 47>();
mag_x_mag_x_update_0_write2_write(mag_x_mag_x_update_0_write2_res, mag_x, d0, d1);
hw_uint<16> mag_x_mag_x_update_0_write3_res = mag_x_update_0_write.extract<48, 63>();
mag_x_mag_x_update_0_write3_write(mag_x_mag_x_update_0_write3_res, mag_x, d0, d1);
}
// sblr30_4_update_0_read
// sblr30_4_rd0
// sblr30_4_rd1
// sblr30_4_rd2
// sblr30_4_rd3
inline hw_uint<64> mag_x_sblr30_4_update_0_read_bundle_read(mag_x_cache& mag_x, int d0, int d1) {
// # of ports in bundle: 4
// sblr30_4_rd0
// sblr30_4_rd1
// sblr30_4_rd2
// sblr30_4_rd3
hw_uint<64> result;
hw_uint<16> sblr30_4_rd0_res = sblr30_4_rd0_select(mag_x, d0, d1);
set_at<0, 64>(result, sblr30_4_rd0_res);
hw_uint<16> sblr30_4_rd1_res = sblr30_4_rd1_select(mag_x, d0, d1);
set_at<16, 64>(result, sblr30_4_rd1_res);
hw_uint<16> sblr30_4_rd2_res = sblr30_4_rd2_select(mag_x, d0, d1);
set_at<32, 64>(result, sblr30_4_rd2_res);
hw_uint<16> sblr30_4_rd3_res = sblr30_4_rd3_select(mag_x, d0, d1);
set_at<48, 64>(result, sblr30_4_rd3_res);
return result;
}
#include "hw_classes.h"
struct mag_y_mag_y_update_0_write0_merged_banks_1_cache {
// RAM Box: {[0, 1916], [0, 1079]}
// Capacity: 1
// # of read delays: 1
fifo<hw_uint<16>, 1> f;
inline hw_uint<16> peek(const int offset) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.peek(0 - offset);
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.push(value);
}
};
struct mag_y_mag_y_update_0_write1_merged_banks_1_cache {
// RAM Box: {[1, 1917], [0, 1079]}
// Capacity: 1
// # of read delays: 1
fifo<hw_uint<16>, 1> f;
inline hw_uint<16> peek(const int offset) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.peek(0 - offset);
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.push(value);
}
};
struct mag_y_mag_y_update_0_write2_merged_banks_1_cache {
// RAM Box: {[2, 1918], [0, 1079]}
// Capacity: 1
// # of read delays: 1
fifo<hw_uint<16>, 1> f;
inline hw_uint<16> peek(const int offset) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.peek(0 - offset);
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.push(value);
}
};
struct mag_y_mag_y_update_0_write3_merged_banks_1_cache {
// RAM Box: {[3, 1919], [0, 1079]}
// Capacity: 1
// # of read delays: 1
fifo<hw_uint<16>, 1> f;
inline hw_uint<16> peek(const int offset) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.peek(0 - offset);
}
inline void push(const hw_uint<16> value) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
return f.push(value);
}
};
struct mag_y_cache {
mag_y_mag_y_update_0_write0_merged_banks_1_cache mag_y_mag_y_update_0_write0_merged_banks_1;
mag_y_mag_y_update_0_write1_merged_banks_1_cache mag_y_mag_y_update_0_write1_merged_banks_1;
mag_y_mag_y_update_0_write2_merged_banks_1_cache mag_y_mag_y_update_0_write2_merged_banks_1;
mag_y_mag_y_update_0_write3_merged_banks_1_cache mag_y_mag_y_update_0_write3_merged_banks_1;
};
inline void mag_y_mag_y_update_0_write0_write(hw_uint<16>& mag_y_mag_y_update_0_write0, mag_y_cache& mag_y, int d0, int d1) {
mag_y.mag_y_mag_y_update_0_write0_merged_banks_1.push(mag_y_mag_y_update_0_write0);
}
inline void mag_y_mag_y_update_0_write1_write(hw_uint<16>& mag_y_mag_y_update_0_write1, mag_y_cache& mag_y, int d0, int d1) {
mag_y.mag_y_mag_y_update_0_write1_merged_banks_1.push(mag_y_mag_y_update_0_write1);
}
inline void mag_y_mag_y_update_0_write2_write(hw_uint<16>& mag_y_mag_y_update_0_write2, mag_y_cache& mag_y, int d0, int d1) {
mag_y.mag_y_mag_y_update_0_write2_merged_banks_1.push(mag_y_mag_y_update_0_write2);
}
inline void mag_y_mag_y_update_0_write3_write(hw_uint<16>& mag_y_mag_y_update_0_write3, mag_y_cache& mag_y, int d0, int d1) {
mag_y.mag_y_mag_y_update_0_write3_merged_banks_1.push(mag_y_mag_y_update_0_write3);
}
inline hw_uint<16> sblr30_4_rd0_select(mag_y_cache& mag_y, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// sblr30_4_rd0 read pattern: { sblr30_4_update_0[d0, d1] -> mag_y[4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { sblr30_4_update_0[d0, d1] -> [1 + d1, 1 + d0, 4] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// DD fold: { }
auto value_mag_y_mag_y_update_0_write0 = mag_y.mag_y_mag_y_update_0_write0_merged_banks_1.peek(/* one reader or all rams */ 0);
return value_mag_y_mag_y_update_0_write0;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> sblr30_4_rd1_select(mag_y_cache& mag_y, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// sblr30_4_rd1 read pattern: { sblr30_4_update_0[d0, d1] -> mag_y[1 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { sblr30_4_update_0[d0, d1] -> [1 + d1, 1 + d0, 4] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// DD fold: { }
auto value_mag_y_mag_y_update_0_write1 = mag_y.mag_y_mag_y_update_0_write1_merged_banks_1.peek(/* one reader or all rams */ 0);
return value_mag_y_mag_y_update_0_write1;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> sblr30_4_rd2_select(mag_y_cache& mag_y, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// sblr30_4_rd2 read pattern: { sblr30_4_update_0[d0, d1] -> mag_y[2 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { sblr30_4_update_0[d0, d1] -> [1 + d1, 1 + d0, 4] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// DD fold: { }
auto value_mag_y_mag_y_update_0_write2 = mag_y.mag_y_mag_y_update_0_write2_merged_banks_1.peek(/* one reader or all rams */ 0);
return value_mag_y_mag_y_update_0_write2;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
inline hw_uint<16> sblr30_4_rd3_select(mag_y_cache& mag_y, int d0, int d1) {
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// sblr30_4_rd3 read pattern: { sblr30_4_update_0[d0, d1] -> mag_y[3 + 4d0, d1] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Read schedule : { sblr30_4_update_0[d0, d1] -> [1 + d1, 1 + d0, 4] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// Write schedule: { mag_y_update_0[d0, d1] -> [1 + d1, 1 + d0, 2] : 0 <= d0 <= 479 and 0 <= d1 <= 1079 }
// DD fold: { }
auto value_mag_y_mag_y_update_0_write3 = mag_y.mag_y_mag_y_update_0_write3_merged_banks_1.peek(/* one reader or all rams */ 0);
return value_mag_y_mag_y_update_0_write3;
#ifndef __VIVADO_SYNTH__
cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << endl;
assert(false);
return 0;
#endif //__VIVADO_SYNTH__
}
// # of bundles = 2
// mag_y_update_0_write
// mag_y_mag_y_update_0_write0
// mag_y_mag_y_update_0_write1
// mag_y_mag_y_update_0_write2
// mag_y_mag_y_update_0_write3
inline void mag_y_mag_y_update_0_write_bundle_write(hw_uint<64>& mag_y_update_0_write, mag_y_cache& mag_y, int d0, int d1) {
hw_uint<16> mag_y_mag_y_update_0_write0_res = mag_y_update_0_write.extract<0, 15>();
mag_y_mag_y_update_0_write0_write(mag_y_mag_y_update_0_write0_res, mag_y, d0, d1);
hw_uint<16> mag_y_mag_y_update_0_write1_res = mag_y_update_0_write.extract<16, 31>();
mag_y_mag_y_update_0_write1_write(mag_y_mag_y_update_0_write1_res, mag_y, d0, d1);
hw_uint<16> mag_y_mag_y_update_0_write2_res = mag_y_update_0_write.extract<32, 47>();
mag_y_mag_y_update_0_write2_write(mag_y_mag_y_update_0_write2_res, mag_y, d0, d1);
hw_uint<16> mag_y_mag_y_update_0_write3_res = mag_y_update_0_write.extract<48, 63>();
mag_y_mag_y_update_0_write3_write(mag_y_mag_y_update_0_write3_res, mag_y, d0, d1);
}
// sblr30_4_update_0_read
// sblr30_4_rd0
// sblr30_4_rd1
// sblr30_4_rd2
// sblr30_4_rd3
inline hw_uint<64> mag_y_sblr30_4_update_0_read_bundle_read(mag_y_cache& mag_y, int d0, int d1) {
// # of ports in bundle: 4
// sblr30_4_rd0
// sblr30_4_rd1
// sblr30_4_rd2
// sblr30_4_rd3
hw_uint<64> result;
hw_uint<16> sblr30_4_rd0_res = sblr30_4_rd0_select(mag_y, d0, d1);
set_at<0, 64>(result, sblr30_4_rd0_res);
hw_uint<16> sblr30_4_rd1_res = sblr30_4_rd1_select(mag_y, d0, d1);
set_at<16, 64>(result, sblr30_4_rd1_res);
hw_uint<16> sblr30_4_rd2_res = sblr30_4_rd2_select(mag_y, d0, d1);
set_at<32, 64>(result, sblr30_4_rd2_res);
hw_uint<16> sblr30_4_rd3_res = sblr30_4_rd3_select(mag_y, d0, d1);
set_at<48, 64>(result, sblr30_4_rd3_res);
return result;
}
// Operation logic
inline void img_update_0(HWStream<hw_uint<64> >& /* buffer_args num ports = 4 */off_chip_img, img_cache& img, int d0, int d1) {
// Consume: off_chip_img
auto off_chip_img_0_c__0_value = off_chip_img.read();
auto compute_result = img_generated_compute_unrolled_4(off_chip_img_0_c__0_value);
// Produce: img
img_img_update_0_write_bundle_write(compute_result, img, d0, d1);
#ifndef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
}
inline void mag_y_update_0(img_cache& img, mag_y_cache& mag_y, int d0, int d1) {
// Consume: img
auto img_0_c__0_value = img_mag_y_update_0_read_bundle_read(img/* source_delay */, d0, d1);
#ifndef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
auto compute_result = mag_y_generated_compute_unrolled_4(img_0_c__0_value);
// Produce: mag_y
mag_y_mag_y_update_0_write_bundle_write(compute_result, mag_y, d0, d1);
#ifndef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
}
inline void mag_x_update_0(img_cache& img, mag_x_cache& mag_x, int d0, int d1) {
// Consume: img
auto img_0_c__0_value = img_mag_x_update_0_read_bundle_read(img/* source_delay */, d0, d1);
#ifndef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
auto compute_result = mag_x_generated_compute_unrolled_4(img_0_c__0_value);
// Produce: mag_x
mag_x_mag_x_update_0_write_bundle_write(compute_result, mag_x, d0, d1);
#ifndef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
}
inline void sblr30_4_update_0(mag_x_cache& mag_x, mag_y_cache& mag_y, HWStream<hw_uint<64> >& /* buffer_args num ports = 4 */sblr30_4, int d0, int d1) {
// Consume: mag_x
auto mag_x_0_c__0_value = mag_x_sblr30_4_update_0_read_bundle_read(mag_x/* source_delay */, d0, d1);
#ifndef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
// Consume: mag_y
auto mag_y_0_c__0_value = mag_y_sblr30_4_update_0_read_bundle_read(mag_y/* source_delay */, d0, d1);
#ifndef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
auto compute_result = sblr30_4_generated_compute_unrolled_4(mag_x_0_c__0_value, mag_y_0_c__0_value);
// Produce: sblr30_4
sblr30_4.write(compute_result);
#ifndef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
}
// Driver function
void sblr30_4_opt(HWStream<hw_uint<64> >& /* get_args num ports = 4 */off_chip_img, HWStream<hw_uint<64> >& /* get_args num ports = 4 */sblr30_4, int num_epochs) {
#ifndef __VIVADO_SYNTH__
ofstream debug_file("sblr30_4_opt_debug.csv");
global_debug_handle = &debug_file;
#endif //__VIVADO_SYNTH__
img_cache img;
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
mag_x_cache mag_x;
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
mag_y_cache mag_y;
#ifdef __VIVADO_SYNTH__
#endif //__VIVADO_SYNTH__
#ifdef __VIVADO_SYNTH__
#pragma HLS inline recursive
#endif // __VIVADO_SYNTH__
for (int epoch = 0; epoch < 30; epoch++) {
// Schedules...
// img_update_0 -> [1*d1*1*1 + 1*0,1*d0*1*1 + 1*0,1*1]
// mag_x_update_0 -> [1*d1*1*1 + 1*1,1*d0*1*1 + 1*1,1*3]
// mag_y_update_0 -> [1*d1*1*1 + 1*1,1*d0*1*1 + 1*1,1*2]
// off_chip_img_update_0 -> [1*d1*1*1 + 1*0,1*d0*1*1 + 1*0,1*0]
// sblr30_4_update_0 -> [1*d1*1*1 + 1*1,1*d0*1*1 + 1*1,1*4]
for (int c0 = -1; c0 <= 1080; c0++) {
for (int c1 = -1; c1 <= 480; c1++) {
#ifdef __VIVADO_SYNTH__
#pragma HLS pipeline II=1
#endif // __VIVADO_SYNTH__
if ((-1 <= c1 && c1 <= 480) && ((c1 - 0) % 1 == 0) && (-1 <= c0 && c0 <= 1080) && ((c0 - 0) % 1 == 0)) {
img_update_0(off_chip_img, img, (c1 - 0) / 1, (c0 - 0) / 1);
}
if ((1 <= c1 && c1 <= 480) && ((c1 - 1) % 1 == 0) && (1 <= c0 && c0 <= 1080) && ((c0 - 1) % 1 == 0)) {
mag_y_update_0(img, mag_y, (c1 - 1) / 1, (c0 - 1) / 1);
}
if ((1 <= c1 && c1 <= 480) && ((c1 - 1) % 1 == 0) && (1 <= c0 && c0 <= 1080) && ((c0 - 1) % 1 == 0)) {
mag_x_update_0(img, mag_x, (c1 - 1) / 1, (c0 - 1) / 1);
}
if ((1 <= c1 && c1 <= 480) && ((c1 - 1) % 1 == 0) && (1 <= c0 && c0 <= 1080) && ((c0 - 1) % 1 == 0)) {
sblr30_4_update_0(mag_x, mag_y, sblr30_4, (c1 - 1) / 1, (c0 - 1) / 1);
}
}
}
}
#ifndef __VIVADO_SYNTH__
debug_file.close();
#endif //__VIVADO_SYNTH__
}
void sblr30_4_opt(HWStream<hw_uint<64> >& /* get_args num ports = 4 */off_chip_img, HWStream<hw_uint<64> >& /* get_args num ports = 4 */sblr30_4) {
sblr30_4_opt(off_chip_img, sblr30_4, 1);
}
#ifdef __VIVADO_SYNTH__
#include "sblr30_4_opt.h"
const int img_update_0_read_num_transfers = 521524;
const int sblr30_4_update_0_write_num_transfers = 518400;
extern "C" {
static void read_img_update_0_read(hw_uint<64>* input, HWStream<hw_uint<64> >& v, const int size) {
hw_uint<64> burst_reg;
int num_transfers = img_update_0_read_num_transfers*30;
for (int i = 0; i < num_transfers; i++) {
#pragma HLS pipeline II=1
burst_reg = input[i];
v.write(burst_reg);
}
}
static void write_sblr30_4_update_0_write(hw_uint<64>* output, HWStream<hw_uint<64> >& v, const int size) {
hw_uint<64> burst_reg;
int num_transfers = sblr30_4_update_0_write_num_transfers*30;
for (int i = 0; i < num_transfers; i++) {
#pragma HLS pipeline II=1
burst_reg = v.read();
output[i] = burst_reg;
}
}
void sblr30_4_opt_accel(hw_uint<64>* img_update_0_read, hw_uint<64>* sblr30_4_update_0_write, const int size) {
#pragma HLS dataflow
#pragma HLS INTERFACE m_axi port = img_update_0_read offset = slave depth = 65536 bundle = gmem0
#pragma HLS INTERFACE m_axi port = sblr30_4_update_0_write offset = slave depth = 65536 bundle = gmem1
#pragma HLS INTERFACE s_axilite port = img_update_0_read bundle = control
#pragma HLS INTERFACE s_axilite port = sblr30_4_update_0_write bundle = control
#pragma HLS INTERFACE s_axilite port = size bundle = control
#pragma HLS INTERFACE s_axilite port = return bundle = control
static HWStream<hw_uint<64> > img_update_0_read_channel;
static HWStream<hw_uint<64> > sblr30_4_update_0_write_channel;
read_img_update_0_read(img_update_0_read, img_update_0_read_channel, size);
sblr30_4_opt(img_update_0_read_channel, sblr30_4_update_0_write_channel, size);
write_sblr30_4_update_0_write(sblr30_4_update_0_write, sblr30_4_update_0_write_channel, size);
}
}
#endif //__VIVADO_SYNTH__
|
// Exceptions.h
#ifndef PARSER_PARSER_EXCEPTIONS_H
#define PARSER_PARSER_EXCEPTIONS_H
#include <stdexcept>
#include <string>
namespace parser
{
/**
* @brief Represents all errors found in parsed document.
*/
class ParseException : public std::logic_error
{
public :
explicit ParseException( const std::string& message ) :
logic_error{ message }
{
}
virtual ~ParseException() noexcept = default;
};
/**
* @brief Represents lexical errors found in parsed document.
*
* Lexical error means incorrect/unsupported lexeme content.
*
* Example: new line in value lexeme.
*/
class LexicalException : public ParseException
{
public :
explicit LexicalException( const std::string& message ) :
ParseException{ message }
{
}
virtual ~LexicalException() noexcept = default;
};
/**
* @brief Represents syntax errors found in parsed document.
*
* Syntax error in most cases means incorrect lexeme position or expected lexeme absence.
*
* Example: matching brace absence.
*/
class SyntaxException : public ParseException
{
public :
explicit SyntaxException( const std::string& message ) :
ParseException{ message }
{
}
virtual ~SyntaxException() noexcept = default;
};
} // parser
#endif // PARSER_PARSER_EXCEPTIONS_H
|
#include<iostream>
#include<conio.h>
using namespace std;
class bags
{
private:
int nobags,l,m,s;
float cl,cm,cs;
public:
bags(int n):nobags(n){l=nobags/20,m=(nobags%20)/10,s=(nobags%20)%10;
if(s==0) s=0; if(s<=5) s=1; else s=2;
cl=l*1.8, cm=m*1.0, cs=s*0.6;}
void setnobags(int n)
{
nobags=n;
}
int getnobags()
{
return nobags;
}
void offer()
{
cout<<"The total no bags are "<<nobags<<endl;
cout<<"Number of boxes are used "<<endl;
cout<<"large box is "<<l<<" = "<<cl<<" $ "<<endl;
cout<<"medium box is "<<m<<" = "<<cm<<" $ "<<endl;
cout<<"small box is "<<s<<" = "<<cs<<" $ "<<endl;
cout<<"The total cost of all the bags is "<<(5.50*nobags)+cl+cm+cs<<" $"<<endl;
}
};
main()
{
int n;
cout<<"Enter no of coffie"<<endl;
cin>>n;
bags c1(n);
c1.setnobags(n);
c1.offer();
getch();
return 0;
}
|
#include <CPU.h>
#include <PSException.h>
#include <iostream>
// TODO: clever c++11 pointer stuff
cpu::cpu(memoryInterface *memIn)
{
// this pointer should be handled better - unique ptr perhaps
memory = memIn;
// initialse coprocessors
cop[0] = &SCC;
cop[2] = >E;
// reg 0 is always 0
gp_reg[0].setMask(0x00000000);
// initialise PC
PC.write(0);
PC_next.write(4);
//
// function pointers
r_type = {
&cpu::SLL, &cpu::RESERVED, &cpu::SRL, &cpu::SRA,
&cpu::SLLV, &cpu::RESERVED, &cpu::SRLV, &cpu::SRAV,
&cpu::JR, &cpu::JALR, &cpu::RESERVED, &cpu::RESERVED,
&cpu::SYSCALL, &cpu::BREAK, &cpu::RESERVED, &cpu::RESERVED,
&cpu::MFHI, &cpu::MTHI, &cpu::MFLO, &cpu::MTLO,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::MULT, &cpu::MULTU, &cpu::DIV, &cpu::DIVU,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::ADD, &cpu::ADDU, &cpu::SUB, &cpu::SUBU,
&cpu::AND, &cpu::OR, &cpu::XOR, &cpu::NOR,
&cpu::RESERVED, &cpu::RESERVED, &cpu::SLT, &cpu::SLTU,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED
};
i_type = {
&cpu::RESERVED, &cpu::BCOND, &cpu::J, &cpu::JAL,
&cpu::BEQ, &cpu::BNE, &cpu::BLEZ, &cpu::BGTZ,
&cpu::ADDI, &cpu::ADDIU, &cpu::SLTI, &cpu::SLTIU,
&cpu::ANDI, &cpu::ORI, &cpu::XORI, &cpu::LUI,
&cpu::COPz, &cpu::COPz, &cpu::COPz, &cpu::COPz,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::LB, &cpu::LH, &cpu::LWL, &cpu::LW,
&cpu::LBU, &cpu::LHU, &cpu::LWR, &cpu::RESERVED,
&cpu::SB, &cpu::SH, &cpu::SWL, &cpu::SW,
&cpu::RESERVED, &cpu::RESERVED, &cpu::SWR, &cpu::RESERVED,
&cpu::LWCz, &cpu::LWCz, &cpu::LWCz, &cpu::LWCz,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::SWCz, &cpu::SWCz, &cpu::SWCz, &cpu::SWCz,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED
};
bcond_type = {
&cpu::BLTZ, &cpu::BGEZ, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED,
&cpu::BLTZAL, &cpu::BGEZAL, &cpu::RESERVED, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED
};
copz_instr = {
&cpu::MFCz, &cpu::RESERVED, &cpu::CFCz, &cpu::RESERVED,
&cpu::MTCz, &cpu::RESERVED, &cpu::CTCz, &cpu::RESERVED,
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, // bc0t/bc0f instructions may need to be added here.
&cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED, &cpu::RESERVED
};
byte_mask[0] = 0xFFFFFF00;
byte_mask[1] = 0xFFFF00FF;
byte_mask[2] = 0xFF00FFFF;
byte_mask[3] = 0x00FFFFFF;
halfword_mask[0] = 0xFFFF0000;
halfword_mask[1] = 0x0000FFFF;
}
void cpu::stepCPU()
{
// ready exception PC, so it can be stored if needed
setEPC();
// get instruction from mem & advance PC
instruction = memory->readWord(PC.read());
PC.write(PC_next.read());
// decode instruction
word opcode = (instruction >> 26) & 0x3F;
try {
// TODO: check for interrupts and throw
if (opcode == 0)
{
// execute r-type instruction
word function = instruction & 0x3F;
r_type[function](this);
}
else
{
// execute i/j-type instruction
i_type[opcode](this);
}
}
catch (psException &e)
{
// set BD
SCC.data_reg[scc::CAUSE].writeBits(branch_delay, 31, 1);
// set CE if exception was coprocessor unusable
if (e.execode() == 11)
SCC.data_reg[scc::CAUSE].writeBits(coproc(), 28, 2);
// set IP
// set SW
// set EXECODE
SCC.data_reg[scc::CAUSE].writeBits(e.execode(), 2, 5);
// move prev to old
word KUp = (SCC.data_reg[scc::SR].read() >> 3) & 1;
word IEp = (SCC.data_reg[scc::SR].read() >> 2) & 1;
SCC.data_reg[scc::SR].writeBits(KUp, 5, 1);
SCC.data_reg[scc::SR].writeBits(IEp, 4, 1);
// move current to prev
word KUc = (SCC.data_reg[scc::SR].read() >> 1) & 1;
word IEc = (SCC.data_reg[scc::SR].read() >> 0) & 1;
SCC.data_reg[scc::SR].writeBits(KUc, 3, 1);
SCC.data_reg[scc::SR].writeBits(IEc, 2, 1);
// set current
SCC.data_reg[scc::SR].writeBits(0, 1, 1);
SCC.data_reg[scc::SR].writeBits(0, 1, 0);
// store exception PC
SCC.data_reg[scc::EPC].writeBits(exception_PC);
// jump to exception handler
// if BEV == 1
if ((SCC.data_reg[scc::SR].read() >> 22) & 1)
{
PC.write(0x1FC00180);
PC_next.write(0x1FC00180);
}
// if BEV == 0
else
{
PC.write(0x00000080);
PC_next.write(0x00000080);
}
}
incrementPCNext();
}
/*** Instructions **************/
void cpu::RESERVED()
{
throw riException();
}
/********** Add/Subtract **************/
void cpu::ADD()
{
word result = source() + target();
if (0x80000000 & (source() ^ result)) // if output sign and input sign are different
{
if ( 0x80000000 & ~(source() ^ target()) ) // if the operand signs are the same
throw ovfException();
}
dest(result);
}
void cpu::ADDU()
{
word result = source() + target();
dest(result);
}
void cpu::ADDI()
{
word result = source() + imm();
if (0x80000000 & (source() ^ result)) // if output sign and input sign are different
{
if (0x80000000 & ~(source() ^ target())) // if the operand signs are the same
throw ovfException();
}
target(result);
}
void cpu::ADDIU()
{
word result = source() + imm();
target(result);
}
void cpu::SUB()
{
word result = source() - target();
if (0x80000000 & (source() ^ result)) // if output sign and input sign are different
{
if (0x80000000 & (source() ^ target())) // if the operand signs are different
throw ovfException();
}
dest(result);
}
void cpu::SUBU()
{
word result = source() - target();
dest(result);
}
/********** Multiply/Divide ***********/
void cpu::MULT()
{
s_doubleword source64 = s_word(source()); // cast to signed 32 bit value, and then cast to 64 bit value
s_doubleword target64 = s_word(target()); // consider including function which returns signed value? (need to cast to 64 bits either way)
s_doubleword result = source64 * target64;
LO.write(result & 0xFFFFFFFF);
HI.write(result >> 32);
}
void cpu::MULTU()
{
doubleword source64 = source(); // cast to 64 bit value
doubleword target64 = target();
doubleword result = source64 * target64;
LO.write(result & 0xFFFFFFFF);
HI.write(result >> 32);
}
void cpu::DIV()
{
LO.write(s_word(source()) / s_word(target()));
HI.write(s_word(source()) % s_word(target()));
}
void cpu::DIVU()
{
LO.write(source() / target());
HI.write(source() % target());
}
/********** Move from/to HI/LO ********/
void cpu::MFHI()
{
dest(HI.read()); // there are some access rules but I guess we can ignore these
}
void cpu::MTHI()
{
HI.write(source());
}
void cpu::MFLO()
{
dest(LO.read());
}
void cpu::MTLO()
{
LO.write(source());
}
/********** Bitwise Logic *************/
void cpu::AND()
{
word result = source() & target();
dest(result);
}
void cpu::ANDI()
{
word imm32 = imm() & 0xFFFF;
word result = source() & imm32;
target(result);
}
void cpu::OR()
{
word result = source() | target();
dest(result);
}
void cpu::ORI()
{
word imm32 = imm() & 0xFFFF;
word result = source() | imm32;
target(result);
}
void cpu::XOR()
{
word result = source() ^ target();
dest(result);
}
void cpu::XORI()
{
word imm32 = imm() & 0xFFFF;
word result = source() ^ imm32;
target(result);
}
void cpu::NOR()
{
word result = source() | target();
result ^= 0xFFFFFFFF;
dest(result);
}
/********** Shifts ********************/
void cpu::SLL()
{
word result = target() << shamt();
dest(result);
}
void cpu::SRL()
{
word result = target() >> shamt();
word mask = (1 << (31 - shamt()));
mask |= mask - 1;
result &= mask;
dest(result);
}
void cpu::SRA()
{
word result = target() >> shamt();
dest(result);
}
void cpu::SLLV()
{
word result = target() << source();
dest(result);
}
void cpu::SRLV()
{
word result = target() >> source();
word mask = (1 << (31 - source()));
mask |= mask - 1;
result &= mask;
dest(result);
}
void cpu::SRAV()
{
word result = target() >> source();
dest(result);
}
/********** Load/Store ****************/
void cpu::LB()
{
unsigned address = source() + imm();
// which byte of the word we are loading
unsigned byte_number = address % 4;
// align the address
address -= byte_number;
// load word and extract byte
word result = memory->readWord(address);
result >>= (byte_number * 8);
result &= 0xFF;
// sign extend
if (result >> 7)
result |= 0xFFFFFF00;
target(result);
}
void cpu::LBU()
{
unsigned address = source() + imm();
// which byte of the word we are loading
unsigned byte_number = address % 4;
// align the address
address -= byte_number;
// load word and extract byte
word result = memory->readWord(address);
result >>= (byte_number * 8);
result &= 0xFF;
target(result);
}
void cpu::LH()
{
unsigned address = source() + imm();
// check alignment
if (address % 2)
throw adelException();
unsigned halfword_number = address % 2;
address -= halfword_number;
// load word and extract halfword
word result = memory->readWord(address);
result >>= (halfword_number * 16);
result &= 0xFFFF;
// sign extend
if (result >> 15)
result |= 0xFFFF0000;
target(result);
}
void cpu::LHU()
{
unsigned address = source() + imm();
// check alignment
if (address % 2)
throw adelException();
unsigned halfword_number = address % 2;
address -= halfword_number;
// load word and extract halfword
word result = memory->readWord(address);
result >>= (halfword_number * 16);
result &= 0xFFFF;
target(result);
}
void cpu::LW()
{
unsigned address = source() + imm();
if (address % 4)
throw adelException();
word result = memory->readWord(address);
target(result);
}
void cpu::LWL()
{
// unaligned address to load
unsigned address = source() + imm();
// number of byte within word to load
unsigned byte_number = address % 4;
// align the address
address -= byte_number;
word load_data = memory->readWord(address);
// shift data to make it most significant
load_data <<= (3 - byte_number) * 8;
// mask target reg so it matches the empty bytes left
word masked_target = target() & (0xFFFFFFFF >> ((1 + byte_number) * 8));
target(load_data | masked_target);
}
void cpu::LWR()
{
// unaligned address to load
unsigned address = source() + imm();
// number of byte within word to load
unsigned byte_number = address % 4;
// align the address
address -= byte_number;
word load_data = memory->readWord(address);
// shift data to make it least significant
load_data >>= byte_number * 8;
// mask target reg so it matches the empty bytes left
word masked_target = target() & (0xFFFFFFFF << ((4 - byte_number) * 8));
target(masked_target | load_data);
}
void cpu::SB()
{
unsigned address = source() + imm();
// number of byte to replace
unsigned byte_number = address % 4;
// align the address
address -= byte_number;
// load word containing byte to store
word data = memory->readWord(address);
// mask byte
word result = (target() & 0xFF) << (byte_number * 8);
// mask data and combine with target data
result |= data & byte_mask[byte_number];
memory->writeWord(address, result);
}
void cpu::SH()
{
unsigned address = source() + imm();
if (address % 2)
throw adesException();
// number of halfword to replace
unsigned halfword_number = address % 2;
// align the address
address -= halfword_number;
// load word containing halfword to store
word data = memory->readWord(address);
// mask halfword
word result = (target() & 0xFFFF) << (halfword_number * 16);
// mask data and combine with target data
result |= data & halfword_mask[halfword_number];
memory->writeWord(address, result);
}
void cpu::SW()
{
word address = source() + imm();
if (address % 4)
throw adesException();
memory->writeWord(address, target());
}
void cpu::SWL()
{
unsigned address = source() + imm();
unsigned byte_number = address % 4;
address -= byte_number;
// shift target data to make it least significant
word reg_data = target() >> ((3 - byte_number) * 8);
// mask data in word so it matches the empty bytes left
word load_data = memory->readWord(address) & (0xFFFFFFFF << ((1 + byte_number) * 8));
memory->writeWord(address, (load_data | reg_data));
}
void cpu::SWR()
{
unsigned address = source() + imm();
unsigned byte_number = address % 4;
address -= byte_number;
// shift target data to make it most significant
word reg_data = target() << (byte_number * 8);
// mask data in word so it matches the empty bytes left
word load_data = memory->readWord(address) & (0xFFFFFFFF >> ((4 - byte_number) * 8));
memory->writeWord(address, (reg_data | load_data));
}
void cpu::LUI()
{
target(imm() << 16);
}
/********** Branch ********************/
void cpu::BEQ()
{
if (source() == target())
branchRoutine(imm());
}
void cpu::BNE()
{
if (source() != target())
branchRoutine(imm());
}
void cpu::BCOND()
{
bcond_type[target_val()](this);
}
void cpu::BGEZ()
{
if (s_word(source()) >= 0)
branchRoutine(imm());
}
void cpu::BGEZAL()
{
if (s_word(source()) >= 0)
{
gp_reg[31].write(PC.read() + 8);
branchRoutine(imm());
}
}
void cpu::BLTZ()
{
if (s_word(source()) < 0)
branchRoutine(imm());
}
void cpu::BLTZAL()
{
if (s_word(source()) < 0)
{
gp_reg[31].write(PC.read() + 8);
branchRoutine(imm());
}
}
void cpu::BGTZ()
{
if (source() > 0)
branchRoutine(imm());
}
void cpu::BLEZ()
{
if (source() <= 0)
branchRoutine(imm());
}
/********** Jump **********************/
void cpu::J()
{
word result = PC.read() & 0xF0000000;
result |= jump() << 2;
PC_next.write(result - 4);
}
void cpu::JAL()
{
gp_reg[31].write(PC.read() + 8);
word result = PC.read() & 0xF0000000;
result |= jump() << 2;
PC_next.write(result - 4);
}
void cpu::JR()
{
PC_next.write(source() - 4);
}
void cpu::JALR()
{
gp_reg[31].write(PC.read() + 8);
PC_next.write(source() - 4);
}
/********** Set ***********************/
void cpu::SLT()
{
word result = (s_word(source()) < s_word(target()));
dest(result);
}
void cpu::SLTU()
{
word result = (source() < target());
dest(result);
}
void cpu::SLTI()
{
s_word imm32 = imm();
word result = (s_word(source()) < imm32);
target(result);
}
void cpu::SLTIU()
{
s_word imm32 = imm();
word result = (source() < word(imm32));
target(result);
}
/********** Special *******************/
void cpu::SYSCALL()
{
throw sysException();
}
void cpu::BREAK()
{
throw bpException();
}
/********** Coprocessor ***************/
void cpu::LWCz()
{
word address = source() + imm();
if (address % 4)
throw adelException();
word data = memory->readWord(address);
cop[coproc()]->writeDataReg(data, target_val());
}
void cpu::SWCz()
{
word address = source() + imm();
if (address % 4)
throw adesException();
word data = cop[coproc()]->readDataReg(target_val());
memory->writeWord(address, data);
}
void cpu::MTCz()
{
// write coproc reg "dest()"
cop[coproc()]->writeDataReg(target(), dest_val());
}
void cpu::MFCz()
{
// write proc reg "dest()"
word data = cop[coproc()]->readDataReg(target_val());
dest(data);
}
void cpu::CTCz()
{
// write control coproc reg "dest()"
cop[coproc()]->writeControlReg(target(), dest_val());
}
void cpu::CFCz()
{
// write proc reg "dest()"
word data = cop[coproc()]->readControlReg(target_val());
dest(data);
}
void cpu::COPz()
{
// check for MT/MF/CT/CF
if (source_val() < 16)
{
copz_instr[source_val()](this);
}
else
{
cop[coproc()]->executeInstruction(instruction);
}
}
|
/****************************************************************************
* *
* Author : lukasz.iwaszkiewicz@gmail.com *
* ~~~~~~~~ *
* License : see COPYING file for details. *
* ~~~~~~~~~ *
****************************************************************************/
#include "MultiTween.h"
#include "Manager.h"
namespace Tween {
MultiTween *multi ()
{
return Manager::getMain ()->newMultiTween ();
}
/*##########################################################################*/
void MultiTween::updateRun (int deltaMs, bool direction)
{
for (TweenList::iterator i = tweens.begin (); i != tweens.end (); ++i) {
(*i)->update (deltaMs, !direction);
}
}
/****************************************************************************/
bool MultiTween::checkEnd (bool direction)
{
bool end = true;
for (TweenList::iterator i = tweens.begin (); i != tweens.end (); ++i) {
if ((*i)->getState () != END) {
end = false;
break;
}
}
return end;
}
/****************************************************************************/
IMultiTween *MultiTween::add (ITween *tween)
{
tween->setParent (this);
tweens.push_back (tween);
return this;
}
/****************************************************************************/
void MultiTween::remove (ITween *tween)
{
tweens.remove (tween);
Manager::getMain ()->free (tween);
}
/****************************************************************************/
void MultiTween::remove (void const *target, bool onlyActive)
{
for (TweenList::iterator i = tweens.begin (); i != tweens.end (); ) {
TweenList::iterator j = i;
++j;
(*i)->remove (target, onlyActive);
i = j;
}
}
/****************************************************************************/
void MultiTween::remove (void const *target, TweeningProperty *property, bool onlyActive)
{
for (TweenList::iterator i = tweens.begin (); i != tweens.end ();) {
TweenList::iterator j = i;
++j;
(*i)->remove (target, property, onlyActive);
i = j;
}
}
} /* namespace Tween */
|
// Copyright (c) 2012-2017 The Cryptonote developers
// Copyright (c) 2018-2023 Conceal Network & Conceal Devs
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include "../IntegrationTestLib/BaseFunctionalTests.h"
#include "../IntegrationTestLib/Logger.h"
#include "gtest/gtest.h"
extern platform_system::Dispatcher globalSystem;
extern cn::Currency currency;
extern Tests::common::BaseFunctionalTestsConfig config;
class TransfersTest :
public Tests::common::BaseFunctionalTests,
public ::testing::Test {
public:
TransfersTest() : BaseFunctionalTests(currency, globalSystem, config) {
}
};
|
#include "DeleteChat.h"
boost::property_tree::ptree DeleteChat::execute(std::shared_ptr<Controller> controller) {
return controller->deleteChat(commandParams);
}
DeleteChat::DeleteChat(boost::property_tree::ptree ¶ms) : BaseCommand("DeleteChat") {
commandParams = params;
}
|
#ifndef SHADER_H
#define SHADER_H
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "debug.h"
#include <string>
class Shader{
public:
Shader();
virtual ~Shader();
GLuint ID;
GLuint blendID;
// Sets the current shader as active
Shader &use();
// Compiles the shader from given source code
void compile(const GLchar *vertexSource, const GLchar *fragmentSource);
private:
//check compile errors shader
void checkCompileErrors(GLuint object, std::string type);
};
#endif //SHADER_H
|
#pragma once
#ifndef Security_Student_H
#define Security_Student_H
#include "student.h"
class SecurityStudent : public Student {
public:
SecurityStudent(string, string, string, string, int, int, int, int, Degree);
Degree GetDegreeProgram();
void Print();
private:
Degree degreeType;
};
#endif
|
// Created on: 1992-08-18
// Created by: Arnaud BOUZY
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ExprIntrp_GenFct_HeaderFile
#define _ExprIntrp_GenFct_HeaderFile
#include <Standard.hxx>
#include <ExprIntrp_Generator.hxx>
class TCollection_AsciiString;
class ExprIntrp_GenFct;
DEFINE_STANDARD_HANDLE(ExprIntrp_GenFct, ExprIntrp_Generator)
//! Implements an interpreter for defining functions.
//! All its functionalities can be found in class
//! GenExp.
class ExprIntrp_GenFct : public ExprIntrp_Generator
{
public:
Standard_EXPORT static Handle(ExprIntrp_GenFct) Create();
Standard_EXPORT void Process (const TCollection_AsciiString& str);
Standard_EXPORT Standard_Boolean IsDone() const;
DEFINE_STANDARD_RTTIEXT(ExprIntrp_GenFct,ExprIntrp_Generator)
protected:
private:
Standard_EXPORT ExprIntrp_GenFct();
Standard_Boolean done;
};
#endif // _ExprIntrp_GenFct_HeaderFile
|
/*
* Copyright (C) 2013 Tom Wong. All rights reserved.
*/
#ifndef __GT_DOC_COMMAND_H__
#define __GT_DOC_COMMAND_H__
#include "gtobject.h"
#include <QtWidgets/QUndoCommand>
GT_BEGIN_NAMESPACE
class GtBookmark;
class GtDocModel;
class GtDocNote;
class GtDocRange;
class GT_VIEW_EXPORT GtDocCommand : public QUndoCommand, public GtObject
{
public:
explicit GtDocCommand(GtDocModel *model,
QUndoCommand *parent = 0);
~GtDocCommand();
public:
void undo();
void redo();
protected:
GtDocModel *m_model;
bool m_done;
};
class GT_VIEW_EXPORT GtAddNoteCommand : public GtDocCommand
{
public:
GtAddNoteCommand(GtDocModel *model,
GtDocNote *note,
QUndoCommand *parent = 0);
~GtAddNoteCommand();
public:
void undo();
void redo();
protected:
GtDocNote *m_note;
};
class GT_VIEW_EXPORT GtAddBookmarkCommand : public GtDocCommand
{
public:
GtAddBookmarkCommand(GtDocModel *model,
GtBookmark *parent,
GtBookmark *before,
GtBookmark *bookmark,
QUndoCommand *parentc = 0);
~GtAddBookmarkCommand();
public:
void undo();
void redo();
protected:
GtBookmark *m_parent;
GtBookmark *m_before;
GtBookmark *m_bookmark;
};
class GT_VIEW_EXPORT GtRenameBookmarkCommand : public GtDocCommand
{
public:
GtRenameBookmarkCommand(GtDocModel *model,
GtBookmark *bookmark,
const QString &name,
QUndoCommand *parent = 0);
~GtRenameBookmarkCommand();
public:
void undo();
void redo();
protected:
void rename();
protected:
GtBookmark *m_bookmark;
QString m_name;
};
class GT_VIEW_EXPORT GtDelBookmarkCommand : public GtDocCommand
{
public:
GtDelBookmarkCommand(GtDocModel *model,
GtBookmark *bookmark,
QUndoCommand *parent = 0);
~GtDelBookmarkCommand();
public:
void undo();
void redo();
protected:
GtBookmark *m_parent;
GtBookmark *m_before;
GtBookmark *m_bookmark;
};
GT_END_NAMESPACE
#endif /* __GT_DOC_COMMAND_H__ */
|
/*
* Copyright (c) 2014-2017 Detlef Vollmann, vollmann engineering gmbh
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#include "shape.hh"
#include "extgraph.hh"
namespace exercise
{
Color::Color(double red, double green, double blue)
: rgbR{red}
, rgbG{green}
, rgbB{blue}
{
}
Color Color::Black{0, 0, 0};
Color Color::White{1, 1, 1};
Pen::Pen(double width)
: w{width}
{
}
Position::Position(double xPos, double yPos)
: x{xPos}
, y{yPos}
{
}
Shape::Shape(std::string const &name_)
: name{name_}
{
}
Shape::Shape(std::string const &name_, Position pos, Color c, Pen pen)
: xy{pos}
, clr{c}
, p{pen}
, name{name_}
{
}
void Shape::draw(cairo_t *cr) const
{
cairo_save(cr);
cairo_move_to(cr, xy.x, xy.y);
cairo_set_source_rgb(cr, clr.rgbR, clr.rgbG, clr.rgbB);
cairo_set_line_width(cr, p.w);
doDraw(cr);
cairo_restore(cr);
}
std::string const &Shape::getName() const
{
return name;
}
void Shape::setName(std::string const &name_)
{
name = name_;
}
void Shape::setPosition(Position pos)
{
xy = pos;
}
void Shape::move(double relX, double relY)
{
xy.x += relX;
xy.y += relY;
}
void Shape::setColor(Color c)
{
clr = c;
}
void Shape::setPen(Pen pen)
{
p = pen;
}
} // namespace exercise
|
#pragma once
#include <QWidget>
class MsWordWrapper : public QWidget
{
public:
MsWordWrapper( QWidget* parent = Q_NULLPTR );
void OpenFile( QString filename );
};
|
#include "DX11RenderSystem.h"
#include "DX11IndexBuffer.h"
#include "dx11Utils.h"
namespace HW{
DX11IndexBuffer::DX11IndexBuffer() : m_uBitsPerIndex(0), m_uIndexCount(0){
m_pIndexBuffer = NULL;
}
DX11IndexBuffer::~DX11IndexBuffer(){
ReleaseInternalRes();
}
// Create index Buffer into ID3D11Buffer*
// Currently create buffer with D3D11_USAGE_IMMUTABLE
void DX11IndexBuffer::CreateInternalRes(RenderSystem* renderSystem, Renderable* renderable){
m_uIndexCount = renderable->m_Indices.size();
m_uBitsPerIndex = 32;
DX11RenderSystem* pSystem = dynamic_cast<DX11RenderSystem*>(renderSystem);
ID3D11Device* pDevice = pSystem->GetDX11Device();
D3D11_BUFFER_DESC bufDesc;
bufDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
bufDesc.ByteWidth = sizeof(UINT)* m_uIndexCount;
bufDesc.CPUAccessFlags = 0;
bufDesc.MiscFlags = 0;
bufDesc.Usage = D3D11_USAGE_IMMUTABLE;
D3D11_SUBRESOURCE_DATA initData;
initData.pSysMem = &renderable->m_Indices[0];
HR(pDevice->CreateBuffer(&bufDesc, &initData, &m_pIndexBuffer));
if (m_pIndexBuffer)
m_valid = true;
}
void DX11IndexBuffer::ReleaseInternalRes(){
if (m_valid){
ReleaseCOM(m_pIndexBuffer);
m_valid = false;
}
}
DXGI_FORMAT DX11IndexBuffer::GetIndexFormat() const{
switch (m_uBitsPerIndex){
case 8:
return DXGI_FORMAT_R8_UINT;
case 16:
return DXGI_FORMAT_R16_UINT;
case 32:
default:
return DXGI_FORMAT_R32_UINT;
}
}
}
|
/**
* @author divyakhetan
* @date 30/12/2018
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
cout << "Enter a number ";
int n;
cin >> n;
for(int i = 1; i <= n; i++){
if((i % 3 == 0) && (i % 5 == 0)) cout << "FizzBuzz ";
else if(i % 3 == 0) cout << "Fizz ";
else if(i % 5 == 0) cout << "Buzz ";
else cout << i << " ";
}
return 0;
}
|
/*
* HTTPStreamer.h
*
* Created on: 2 Mar 2011
* Author: two
*
* Currently used to transport data as a application/octetstream in HTTP. Just ignores the header/request being
* received and gives a HTTP/1.0 200 OK status. This class is paritally threaded. But does not listen, pass in a
* socket of a premade connection.
*/
#ifndef HTTPSTREAMER_H_
#define HTTPSTREAMER_H_
#include <iostream>
using namespace std;
extern "C" {
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h> /* socket types */
#include <netinet/in.h>
#include <arpa/inet.h>
//#include <sys/socket.h> /* socket definitions */
//#include <sys/types.h> /* socket types */
//#include <arpa/inet.h> /* inet (3) funtions */
#include <unistd.h> /* misc. UNIX functions */
#include <pthread.h>
}
#include "MyThread.h"
#include "Packetiser.h"
#include "IOBuffer.h"
class HTTPStreamer: public MyThread {
private:
int m_fdSocket;
struct sockaddr_in m_CliAddr;
bool m_bHeaderSent;
pthread_mutex_t m_mHeaderSentLock; // Lock used for both HeaderSent AND ClientDead.
bool m_bClientDead;
int *m_pFirstListLength;
uint8_t **m_pFirstList;
int m_nFirstListSize;
bool m_bFirstEnabled;
Packetiser *m_Packetiser; // this is an experiment.
IOBuffer *m_IOBuffer;
bool m_bSentFirstIFrame;
bool m_bMP4HeaderHack; //The hack that injects the moov box of mp4v stream.
public:
HTTPStreamer(int socket);
int setUpPacketiser(char* type, AVCodecContext * codecCtx);
void setFirstList(uint8_t ** buffs, int* lengths, int size);
void Setup();
void Execute();
void rejectConnection();
void sendPacket(char* buffer, int size);
bool isClientDead();
void packitiseAndSend(AVPacket *packet, bool isIframe);
virtual ~HTTPStreamer();
};
#endif /* HTTPSTREAMER_H_ */
|
#include <bits/stdc++.h>
using namespace std;
#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define MAXN 100
struct cube{
char color[6];
}A,B;
void clockwise(){
char tmp = B.color[4];
B.color[4] = B.color[2];
B.color[2] = B.color[1];
B.color[1] = B.color[3];
B.color[3] = tmp;
}
void forword(){
char tmp = B.color[5];
B.color[5] = B.color[4];
B.color[4] = B.color[0];
B.color[0] = B.color[1];
B.color[1] = tmp;
}
void turnRight(){
char tmp = B.color[3];
B.color[3] = B.color[0];
B.color[0] = B.color[2];
B.color[2] = B.color[5];
B.color[5] = tmp;
}
bool cmp(){
for(int i = 0; i < 6 ; i++ )
if( A.color[i] != B.color[i] )
return false;
return true;
}
int main(int argc, char const *argv[])
{
string str;
while( cin >> str ){
for(int i = 0 ; i < 6 ; i++ ){
A.color[i] = str[i];
B.color[i] = str[i+6];
}
bool ans = false;
for(int i = 0 ; i < 4 ; i++ ){
for(int j = 0 ; j < 4 ; j++ ){
if( cmp() )
ans = true;
clockwise();
}
forword();
}
for(int i = 0 ; i < 4 ; i++ ){
for(int j = 0 ; j < 4 ; j++ ){
if( cmp() )
ans = true;
clockwise();
}
turnRight();
}
cout << (ans?"TRUE":"FALSE") << endl;
}
return 0;
}
|
#include "Player.h"
#include "PlayerStandingState.h"
#include "PlayerJumpingState.h"
vector<RECT> LoadRECT(PlayerState::StateName state)
{
vector<RECT> listSourceRect;
RECT rect;
switch (state)
{
case PlayerState::JumpString:
rect.left = 10; rect.top = 1870; rect.right = rect.left + 34; rect.bottom = rect.top + 72; listSourceRect.push_back(rect);
rect.left = 65; rect.top = 1873; rect.right = rect.left + 24; rect.bottom = rect.top + 76; listSourceRect.push_back(rect);
rect.left = 100; rect.top = 1874; rect.right = rect.left + 36; rect.bottom = rect.top + 70; listSourceRect.push_back(rect);
rect.left = 144; rect.top = 1874; rect.right = rect.left + 48; rect.bottom = rect.top + 63; listSourceRect.push_back(rect);
rect.left = 204; rect.top = 1875; rect.right = rect.left + 59; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 281; rect.top = 1876; rect.right = rect.left + 59; rect.bottom = rect.top + 40; listSourceRect.push_back(rect);
rect.left = 354; rect.top = 1869; rect.right = rect.left + 52; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 422; rect.top = 1871; rect.right = rect.left + 47; rect.bottom = rect.top + 66; listSourceRect.push_back(rect);
rect.left = 482; rect.top = 1866; rect.right = rect.left + 45; rect.bottom = rect.top + 74; listSourceRect.push_back(rect);
break;
case PlayerState::Stop:
rect.left = 11; rect.top = 1293; rect.right = rect.left + 57; rect.bottom = rect.top + 56; listSourceRect.push_back(rect);
rect.left = 83; rect.top = 1294; rect.right = rect.left + 43; rect.bottom = rect.top + 55; listSourceRect.push_back(rect);
rect.left = 134; rect.top = 1284; rect.right = rect.left + 51; rect.bottom = rect.top + 65; listSourceRect.push_back(rect);
rect.left = 200; rect.top = 1283; rect.right = rect.left + 46; rect.bottom = rect.top + 64; listSourceRect.push_back(rect);
rect.left = 256; rect.top = 1285; rect.right = rect.left + 41; rect.bottom = rect.top + 63; listSourceRect.push_back(rect);
rect.left = 309; rect.top = 1306; rect.right = rect.left + 55; rect.bottom = rect.top + 45; listSourceRect.push_back(rect);
rect.left = 376; rect.top = 1308; rect.right = rect.left + 52; rect.bottom = rect.top + 43; listSourceRect.push_back(rect);
rect.left = 437; rect.top = 1300; rect.right = rect.left + 45; rect.bottom = rect.top + 51; listSourceRect.push_back(rect);
rect.left = 498; rect.top = 1294; rect.right = rect.left + 51; rect.bottom = rect.top + 51; listSourceRect.push_back(rect);
break;
case PlayerState::Falling:
rect.left = 333;
rect.top = 828;
rect.right = rect.left + 42;
rect.bottom = rect.top + 68;
listSourceRect.push_back(rect);
rect.left = 387;
rect.top = 815;
rect.right = rect.left + 41;
rect.bottom = rect.top + 83;
listSourceRect.push_back(rect);
rect.left = 447;
rect.top = 806;
rect.right = rect.left + 35;
rect.bottom = rect.top + 96;
listSourceRect.push_back(rect);
rect.left = 501;
rect.top = 806;
rect.right = rect.left + 38;
rect.bottom = rect.top + 98;
listSourceRect.push_back(rect);
break;
case PlayerState::Revive:
rect.left = 2; rect.top = 2472; rect.right = rect.left + 63; rect.bottom = rect.top + 68; listSourceRect.push_back(rect);
rect.left = 77; rect.top = 2475; rect.right = rect.left + 57; rect.bottom = rect.top + 65; listSourceRect.push_back(rect);
rect.left = 143; rect.top = 2508; rect.right = rect.left + 19; rect.bottom = rect.top + 32; listSourceRect.push_back(rect);
rect.left = 173; rect.top = 2503; rect.right = rect.left + 23; rect.bottom = rect.top + 37; listSourceRect.push_back(rect);
rect.left = 205; rect.top = 2495; rect.right = rect.left + 25; rect.bottom = rect.top + 45; listSourceRect.push_back(rect);
rect.left = 243; rect.top = 2483; rect.right = rect.left + 27; rect.bottom = rect.top + 57; listSourceRect.push_back(rect);
rect.left = 278; rect.top = 2474; rect.right = rect.left + 38; rect.bottom = rect.top + 66; listSourceRect.push_back(rect);
rect.left = 333; rect.top = 2460; rect.right = rect.left + 37; rect.bottom = rect.top + 80; listSourceRect.push_back(rect);
rect.left = 382; rect.top = 2460; rect.right = rect.left + 42; rect.bottom = rect.top + 83; listSourceRect.push_back(rect);
rect.left = 442; rect.top = 2454; rect.right = rect.left + 53; rect.bottom = rect.top + 86; listSourceRect.push_back(rect);
rect.left = 510; rect.top = 2441; rect.right = rect.left + 43; rect.bottom = rect.top + 99; listSourceRect.push_back(rect);
rect.left = 563; rect.top = 2426; rect.right = rect.left + 50; rect.bottom = rect.top + 114; listSourceRect.push_back(rect);
rect.left = 623; rect.top = 2407; rect.right = rect.left + 45; rect.bottom = rect.top + 133; listSourceRect.push_back(rect);
rect.left = 682; rect.top = 2400; rect.right = rect.left + 39; rect.bottom = rect.top + 140; listSourceRect.push_back(rect);
break;
case PlayerState::Bung:
rect.left = 12; rect.top = 1154; rect.right = rect.left + 49; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 76; rect.top = 1162; rect.right = rect.left + 37; rect.bottom = rect.top + 31; listSourceRect.push_back(rect);
rect.left = 135; rect.top = 1160; rect.right = rect.left + 35; rect.bottom = rect.top + 33; listSourceRect.push_back(rect);
rect.left = 190; rect.top = 1160; rect.right = rect.left + 38; rect.bottom = rect.top + 39; listSourceRect.push_back(rect);
rect.left = 252; rect.top = 1165; rect.right = rect.left + 38; rect.bottom = rect.top + 30; listSourceRect.push_back(rect);
rect.left = 306; rect.top = 1158; rect.right = rect.left + 37; rect.bottom = rect.top + 37; listSourceRect.push_back(rect);
rect.left = 362; rect.top = 1161; rect.right = rect.left + 38; rect.bottom = rect.top + 34; listSourceRect.push_back(rect);
rect.left = 417; rect.top = 1156; rect.right = rect.left + 42; rect.bottom = rect.top + 41; listSourceRect.push_back(rect);
break;
case PlayerState::ThrowCLimb:
rect.left = 13; rect.top = 1666; rect.right = rect.left + 37; rect.bottom = rect.top + 86; listSourceRect.push_back(rect);
rect.left = 65; rect.top = 1666; rect.right = rect.left + 41; rect.bottom = rect.top + 86; listSourceRect.push_back(rect);
rect.left = 125; rect.top = 1665; rect.right = rect.left + 51; rect.bottom = rect.top + 87; listSourceRect.push_back(rect);
rect.left = 192; rect.top = 1664; rect.right = rect.left + 31; rect.bottom = rect.top + 88; listSourceRect.push_back(rect);
rect.left = 236; rect.top = 1664; rect.right = rect.left + 56; rect.bottom = rect.top + 88; listSourceRect.push_back(rect);
break;
case PlayerState::Fired:
rect.left = 9; rect.top = 2167; rect.right = rect.left + 42; rect.bottom = rect.top + 45; listSourceRect.push_back(rect);
rect.left = 58; rect.top = 2161; rect.right = rect.left + 55; rect.bottom = rect.top + 51; listSourceRect.push_back(rect);
rect.left = 122; rect.top = 2162; rect.right = rect.left + 59; rect.bottom = rect.top + 49; listSourceRect.push_back(rect);
rect.left = 189; rect.top = 2163; rect.right = rect.left + 80; rect.bottom = rect.top + 47; listSourceRect.push_back(rect);
rect.left = 282; rect.top = 2160; rect.right = rect.left + 61; rect.bottom = rect.top + 50; listSourceRect.push_back(rect);
rect.left = 351; rect.top = 2161; rect.right = rect.left + 59; rect.bottom = rect.top + 48; listSourceRect.push_back(rect);
break;
case PlayerState::Standing:
rect.left = 3; rect.top = 9; rect.right = rect.left + 37; rect.bottom = rect.top + 49; listSourceRect.push_back(rect);
rect.left = 47; rect.top = 11; rect.right = rect.left + 41; rect.bottom = rect.top + 46; listSourceRect.push_back(rect);
rect.left = 95; rect.top = 6; rect.right = rect.left + 40; rect.bottom = rect.top + 51; listSourceRect.push_back(rect);
rect.left = 143; rect.top = 3; rect.right = rect.left + 44; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 143; rect.top = 3; rect.right = rect.left + 44; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 143; rect.top = 3; rect.right = rect.left + 44; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 143; rect.top = 3; rect.right = rect.left + 44; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 143; rect.top = 3; rect.right = rect.left + 44; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 197; rect.top = 6; rect.right = rect.left + 41; rect.bottom = rect.top + 50; listSourceRect.push_back(rect);
rect.left = 250; rect.top = 5; rect.right = rect.left + 42; rect.bottom = rect.top + 50; listSourceRect.push_back(rect);
rect.left = 303; rect.top = 2; rect.right = rect.left + 44; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 303; rect.top = 2; rect.right = rect.left + 44; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 303; rect.top = 2; rect.right = rect.left + 44; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 303; rect.top = 2; rect.right = rect.left + 44; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 303; rect.top = 2; rect.right = rect.left + 44; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 303; rect.top = 2; rect.right = rect.left + 44; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 6; rect.top = 83; rect.right = rect.left + 40; rect.bottom = rect.top + 51; listSourceRect.push_back(rect);
rect.left = 51; rect.top = 81; rect.right = rect.left + 61; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 116; rect.top = 80; rect.right = rect.left + 62; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 180; rect.top = 81; rect.right = rect.left + 41; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 228; rect.top = 81; rect.right = rect.left + 39; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 275; rect.top = 81; rect.right = rect.left + 36; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 319; rect.top = 81; rect.right = rect.left + 40; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 366; rect.top = 79; rect.right = rect.left + 41; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 417; rect.top = 61; rect.right = rect.left + 42; rect.bottom = rect.top + 72; listSourceRect.push_back(rect);
rect.left = 465; rect.top = 57; rect.right = rect.left + 41; rect.bottom = rect.top + 76; listSourceRect.push_back(rect);
rect.left = 516; rect.top = 63; rect.right = rect.left + 41; rect.bottom = rect.top + 70; listSourceRect.push_back(rect);
rect.left = 568; rect.top = 72; rect.right = rect.left + 41; rect.bottom = rect.top + 61; listSourceRect.push_back(rect);
rect.left = 619; rect.top = 80; rect.right = rect.left + 41; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 668; rect.top = 80; rect.right = rect.left + 40; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 715; rect.top = 81; rect.right = rect.left + 39; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 228; rect.top = 81; rect.right = rect.left + 39; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 275; rect.top = 81; rect.right = rect.left + 36; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 319; rect.top = 81; rect.right = rect.left + 40; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 366; rect.top = 79; rect.right = rect.left + 41; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 417; rect.top = 61; rect.right = rect.left + 42; rect.bottom = rect.top + 72; listSourceRect.push_back(rect);
rect.left = 465; rect.top = 57; rect.right = rect.left + 41; rect.bottom = rect.top + 76; listSourceRect.push_back(rect);
rect.left = 516; rect.top = 63; rect.right = rect.left + 41; rect.bottom = rect.top + 70; listSourceRect.push_back(rect);
rect.left = 568; rect.top = 72; rect.right = rect.left + 41; rect.bottom = rect.top + 61; listSourceRect.push_back(rect);
rect.left = 619; rect.top = 80; rect.right = rect.left + 41; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 668; rect.top = 80; rect.right = rect.left + 40; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 715; rect.top = 81; rect.right = rect.left + 39; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 228; rect.top = 81; rect.right = rect.left + 39; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 275; rect.top = 81; rect.right = rect.left + 36; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 319; rect.top = 81; rect.right = rect.left + 40; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 366; rect.top = 79; rect.right = rect.left + 41; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 417; rect.top = 61; rect.right = rect.left + 42; rect.bottom = rect.top + 72; listSourceRect.push_back(rect);
rect.left = 465; rect.top = 57; rect.right = rect.left + 41; rect.bottom = rect.top + 76; listSourceRect.push_back(rect);
rect.left = 516; rect.top = 63; rect.right = rect.left + 41; rect.bottom = rect.top + 70; listSourceRect.push_back(rect);
rect.left = 568; rect.top = 72; rect.right = rect.left + 41; rect.bottom = rect.top + 61; listSourceRect.push_back(rect);
rect.left = 619; rect.top = 80; rect.right = rect.left + 41; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 668; rect.top = 80; rect.right = rect.left + 40; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 715; rect.top = 81; rect.right = rect.left + 39; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 3; rect.top = 165; rect.right = rect.left + 36; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 46; rect.top = 165; rect.right = rect.left + 40; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 91; rect.top = 163; rect.right = rect.left + 41; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 140; rect.top = 155; rect.right = rect.left + 37; rect.bottom = rect.top + 62; listSourceRect.push_back(rect);
rect.left = 188; rect.top = 151; rect.right = rect.left + 40; rect.bottom = rect.top + 66; listSourceRect.push_back(rect);
rect.left = 238; rect.top = 159; rect.right = rect.left + 42; rect.bottom = rect.top + 57; listSourceRect.push_back(rect);
rect.left = 287; rect.top = 168; rect.right = rect.left + 38; rect.bottom = rect.top + 48; listSourceRect.push_back(rect);
rect.left = 334; rect.top = 168; rect.right = rect.left + 39; rect.bottom = rect.top + 48; listSourceRect.push_back(rect);
rect.left = 378; rect.top = 168; rect.right = rect.left + 39; rect.bottom = rect.top + 48; listSourceRect.push_back(rect);
rect.left = 425; rect.top = 156; rect.right = rect.left + 37; rect.bottom = rect.top + 60; listSourceRect.push_back(rect);
rect.left = 472; rect.top = 150; rect.right = rect.left + 37; rect.bottom = rect.top + 66; listSourceRect.push_back(rect);
rect.left = 519; rect.top = 143; rect.right = rect.left + 35; rect.bottom = rect.top + 73; listSourceRect.push_back(rect);
rect.left = 568; rect.top = 138; rect.right = rect.left + 38; rect.bottom = rect.top + 78; listSourceRect.push_back(rect);
rect.left = 615; rect.top = 155; rect.right = rect.left + 41; rect.bottom = rect.top + 61; listSourceRect.push_back(rect);
rect.left = 666; rect.top = 163; rect.right = rect.left + 41; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 715; rect.top = 163; rect.right = rect.left + 40; rect.bottom = rect.top + 53; listSourceRect.push_back(rect);
rect.left = 762; rect.top = 164; rect.right = rect.left + 39; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
break;
case PlayerState::ClimbingHori:
rect.top = 1469;
rect.bottom = 1552;
rect.left = 10;
rect.right = 50; listSourceRect.push_back(rect);
rect.left = 57;
rect.right = 120; listSourceRect.push_back(rect);
rect.left = 115;
rect.right = 178; listSourceRect.push_back(rect);
rect.left = 176;
rect.right = 239; listSourceRect.push_back(rect);
rect.left = 242;
rect.right = 301; listSourceRect.push_back(rect);
rect.left = 303;
rect.right = 362; listSourceRect.push_back(rect);
rect.left = 365;
rect.right = 424; listSourceRect.push_back(rect);
rect.left = 430;
rect.right = 495; listSourceRect.push_back(rect);
rect.left = 504;
rect.right = 566; listSourceRect.push_back(rect);
rect.left = 566;
rect.right = 628; listSourceRect.push_back(rect);
rect.top = 1560;
rect.right = 178;
rect.bottom = rect.top + 92;
rect.left = rect.right + 44; listSourceRect.push_back(rect);
break;
case PlayerState::Running:
for (int i = 1; i <= 13; i++)
{
rect.top = 1212;
rect.bottom = 1275;
switch (i)
{
case 1:
{
rect.left = 7;
rect.right = 57;
break;
}
case 2:
{
rect.left = 60;
rect.right = 110;
break;
}
case 3:
{
rect.left = 113;
rect.right = 163;
break;
}
case 4:
{
rect.left = 162;
rect.right = 212;
break;
}
case 5:
{
rect.left = 219;
rect.right = 279;
break;
}
case 6:
{
rect.left = 276;
rect.right = 334;
break;
}
case 7:
{
rect.left = 326;
rect.right = 386;
break;
}
case 8:
{
rect.left = 376;
rect.right = 436;
break;
}
case 9:
{
rect.left = 431;
rect.right = 479;
break;
}
case 10:
{
rect.left = 487;
rect.right = 543;
break;
}
case 11:
{
rect.left = 547;
rect.right = 608;
break;
}
case 12:
{
rect.left = 609;
rect.right = 671;
break;
}
case 13:
{
rect.left = 669;
rect.right = 731;
break;
}
}
listSourceRect.push_back(rect);
}
break;
case PlayerState::Jumping:
rect.top = 703;
rect.bottom = rect.top + 45;
rect.left = 7;
rect.right = rect.left + 44;
listSourceRect.push_back(rect);
rect.top = 683;
rect.bottom = rect.top + 79;
rect.left = 66;
rect.right = rect.left + 45;
listSourceRect.push_back(rect);
rect.top = 686;
rect.bottom = rect.top + 60;
rect.left = 124;
rect.right = rect.left + 57;
listSourceRect.push_back(rect);
rect.top = 697;
rect.bottom = rect.top + 44;
rect.left = 199;
rect.right = rect.left + 59;
listSourceRect.push_back(rect);
rect.top = 694;
rect.bottom = rect.top + 50;
rect.left = 273;
rect.right = rect.left + 63;
listSourceRect.push_back(rect);
rect.top = 692;
rect.bottom = rect.top + 52;
rect.left = 348;
rect.right = rect.left + 61;
listSourceRect.push_back(rect);
break;
case PlayerState::Die:
break;
case PlayerState::Throwing:
rect.top = 234;
rect.bottom = rect.top + 58;
rect.left = 6;
rect.right = rect.left + 44;
listSourceRect.push_back(rect);
rect.top = 230;
rect.bottom = rect.top + 61;
rect.left = 56;
rect.right = rect.left + 43;
listSourceRect.push_back(rect);
rect.top = 230;
rect.bottom = rect.top + 61;
rect.left = 106;
rect.right = rect.left + 42;
listSourceRect.push_back(rect);
rect.top = 230;
rect.bottom = rect.top + 60;
rect.left = 161;
rect.right = rect.left + 59;
listSourceRect.push_back(rect);
rect.top = 233;
rect.bottom = rect.top + 60;
rect.left = 220;
rect.right = rect.left + 40;
listSourceRect.push_back(rect);
rect.top = 237;
rect.bottom = rect.top + 55;
rect.left = 267;
rect.right = rect.left + 40;
listSourceRect.push_back(rect);
break;
case PlayerState::Climbing:
for (int i = 1; i <= 10; i++)
{
RECT rect;
rect.top = 1360;
float x = 44;
rect.right = x * i;
rect.left = x * i - x + 1;
rect.bottom = 1440;
listSourceRect.push_back(rect);
}
case PlayerState::Fighting:
rect.top = 313;
rect.bottom = 388;
rect.left = 6;
rect.right = rect.left + 44;
listSourceRect.push_back(rect);
rect.top = 313;
rect.bottom = 388;
rect.left = 54;
rect.right = rect.left + 52;
listSourceRect.push_back(rect);
rect.top = 313;
rect.bottom = 388;
rect.left = 113;
rect.right = rect.left + 47;
listSourceRect.push_back(rect);
rect.top = 313;
rect.bottom = 388;
rect.left = 171;
rect.right = rect.left + 83;
listSourceRect.push_back(rect);
rect.top = 313;
rect.bottom = 388;
rect.left = 260;
rect.right = rect.left + 51;
listSourceRect.push_back(rect);
break;
case PlayerState::Sit:
rect.top = 499;
rect.bottom = 550;
rect.left = 204;
rect.right = rect.left + 43;
listSourceRect.push_back(rect);
rect.top = 499;
rect.bottom = 550;
rect.left = 258;
rect.right = rect.left + 49;
listSourceRect.push_back(rect);
rect.top = 499;
rect.bottom = 550;
rect.left = 314;
rect.right = rect.left + 56;
listSourceRect.push_back(rect);
rect.top = 499;
rect.bottom = 550;
rect.left = 377;
rect.right = rect.left + 55;
listSourceRect.push_back(rect);
break;
case PlayerState::SitFight:
rect.left = 7;
rect.top = 638;
rect.right = rect.left + 50;
rect.bottom = rect.top + 35;
listSourceRect.push_back(rect);
rect.left = 62;
rect.top = 640;
rect.right = rect.left + 49;
rect.bottom = rect.top + 34;
listSourceRect.push_back(rect);
rect.left = 114;
rect.top = 640;
rect.right = rect.left + 72;
rect.bottom = rect.top + 34;
listSourceRect.push_back(rect);
rect.left = 189;
rect.top = 639;
rect.right = rect.left + 95;
rect.bottom = rect.top + 34;
listSourceRect.push_back(rect);
rect.left = 298;
rect.top = 640;
rect.right = rect.left + 84;
rect.bottom = rect.top + 34;
listSourceRect.push_back(rect);
rect.left = 391;
rect.top = 640;
rect.right = rect.left + 73;
rect.bottom = rect.top + 34;
listSourceRect.push_back(rect);
rect.left = 473;
rect.top = 640;
rect.right = rect.left + 48;
rect.bottom = rect.top + 34;
listSourceRect.push_back(rect);
break;
case PlayerState::JumpThrow:
rect.left = 19; rect.top = 1005; rect.right = rect.left + 49; rect.bottom = rect.top + 54; listSourceRect.push_back(rect);
rect.left = 77; rect.top = 1007; rect.right = rect.left + 43; rect.bottom = rect.top + 51; listSourceRect.push_back(rect);
rect.left = 132; rect.top = 1008; rect.right = rect.left + 38; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 185; rect.top = 1008; rect.right = rect.left + 52; rect.bottom = rect.top + 52; listSourceRect.push_back(rect);
rect.left = 253; rect.top = 1012; rect.right = rect.left + 40; rect.bottom = rect.top + 51; listSourceRect.push_back(rect);
case PlayerState::SitThrow:
rect.left = 9; rect.top = 571; rect.right = rect.left + 36; rect.bottom = rect.top + 43; listSourceRect.push_back(rect);
rect.left = 58; rect.top = 567; rect.right = rect.left + 37; rect.bottom = rect.top + 47; listSourceRect.push_back(rect);
rect.left = 107; rect.top = 571; rect.right = rect.left + 50; rect.bottom = rect.top + 47; listSourceRect.push_back(rect);
rect.left = 164; rect.top = 578; rect.right = rect.left + 82; rect.bottom = rect.top + 36; listSourceRect.push_back(rect);
rect.left = 256; rect.top = 579; rect.right = rect.left + 57; rect.bottom = rect.top + 36; listSourceRect.push_back(rect);
default:
break;
}
return listSourceRect;
}
int curApple = 0;
Player::Player()
{
mAnimationStanding = new Animation("Resources/Aladdin.png", LoadRECT(PlayerState::Standing).size(), LoadRECT(PlayerState::Standing), (float)1 / 10,D3DXVECTOR2(0.5,1), D3DCOLOR_XRGB(255, 0, 255),Entity::Entity::EntityTypes::PlayerOne);
mAnimationJumping = new Animation("Resources/Aladdin.png", 6, LoadRECT(PlayerState::Jumping), (float)1 / 30, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::Entity::EntityTypes::PlayerOne);
mAnimationRunning = new Animation("Resources/Aladdin.png", 13, LoadRECT(PlayerState::Running), (float)1 / 20, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationThrowing = new Animation("Resources/Aladdin.png", 6, LoadRECT(PlayerState::Throwing), (float)1 / 25, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationClimbing = new Animation("Resources/Aladdin.png", 10, LoadRECT(PlayerState::Climbing), (float)1 / 30, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationFighting=new Animation("Resources/Aladdin.png", 5, LoadRECT(PlayerState::Fighting), (float)1 / 20, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationSiting= new Animation("Resources/Aladdin.png", 4, LoadRECT(PlayerState::Sit), (float)1 / 20, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationSitFight= new Animation("Resources/Aladdin.png",7, LoadRECT(PlayerState::SitFight), (float)1 / 20, D3DXVECTOR2(0.2, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationJumpThrow= new Animation("Resources/Aladdin.png",5, LoadRECT(PlayerState::JumpThrow), (float)1 /30, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationSitThrow = new Animation("Resources/Aladdin.png", 5, LoadRECT(PlayerState::SitThrow), (float)1 / 20, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationFired=new Animation("Resources/Aladdin.png", 6, LoadRECT(PlayerState::Fired), (float)1 /15, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationThrowClimb= new Animation("Resources/Aladdin.png",5, LoadRECT(PlayerState::ThrowCLimb), (float)1 / 15, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationBung= new Animation("Resources/Aladdin.png",8, LoadRECT(PlayerState::Bung), (float)1 / 15, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationClimbHori= new Animation("Resources/Aladdin.png",11, LoadRECT(PlayerState::ClimbingHori), (float)1 /15, D3DXVECTOR2(0.5, 0), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationRevive= new Animation("Resources/Aladdin.png", 14, LoadRECT(PlayerState::Revive), (float)1 / 15, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationFalling= new Animation("Resources/Aladdin.png", 4, LoadRECT(PlayerState::Falling), (float)1 /2, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationStopping = new Animation("Resources/Aladdin.png", 9, LoadRECT(PlayerState::Stop), (float)1 / 45, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
mAnimationJumpString = new Animation("Resources/Aladdin.png", 9, LoadRECT(PlayerState::JumpString), (float)1 / 20, D3DXVECTOR2(0.5, 1), D3DCOLOR_XRGB(255, 0, 255), Entity::EntityTypes::PlayerOne);
Tag = Entity::EntityTypes::PlayerOne;
this->mPlayerData = new PlayerData();
this->mPlayerData->player = this;
this->vx = 0;
this->vy = 0;
this->SetState(new PlayerFallingState(this->mPlayerData));
listApple.push_back(new Apple(Entity::AppleThrow));
listApple.push_back(new Apple(Entity::AppleThrow));
listApple.push_back(new Apple(Entity::AppleThrow));
allowJump = true;
allowThrow = true;
CheckPoint = D3DXVECTOR2(50, 300);
}
Player::~Player()
{
delete mAnimationStanding, mAnimationJumping, mAnimationRunning, mAnimationThrowing, mAnimationClimbing, mAnimationFighting, mAnimationSiting,
mAnimationSitFight, mAnimationJumpThrow, mAnimationSitThrow, mAnimationFired, mAnimationThrowClimb, mAnimationBung, mAnimationClimbHori,
mAnimationRevive, mAnimationFalling;
}
void Player::Update(float dt)
{
LastPosition = D3DXVECTOR2(GetPosition().x, GetPosition().y);
if (this->mPlayerData->state)
{
this->mPlayerData->state->Update(dt);
}
mCurrentAnimation->Update(dt);
Entity::Update(dt);
for (int i = 0; i < listApple.size(); i++)
{
Apple *temp = listApple.at(i);
temp->Update(dt);
if (temp->GetCurrentState() == AppleState::NONE)
{
temp->SetPosition(D3DXVECTOR3(0, posY - 30, 0));
}
}
if (HPCount > 10) HPCount =10;
if (HPCount == 0 && mCurrentState!=PlayerState::Revive)
{
HPCount = 10;
SetPosition(CheckPoint);
SetState(new PLayerRevive(mPlayerData));
}
}
void Player::HandleKeyboard(std::map<int, bool> keys)
{
if (this->mPlayerData->state)
{
this->mPlayerData->state->HandleKeyboard(keys);
}
}
void Player::OnKeyPressed(int key)
{
//Nhay
if (key == VK_SPACE)
{
if (allowJump)
{
if (mCurrentState == PlayerState::Running || mCurrentState == PlayerState::Standing)
{
//vx = 150;
this->mPlayerData->player->GetCurrentAnimation()->Reset();
this->SetState(new PlayerJumpingState(this->mPlayerData));
}
allowJump = false;
}
}
//Nem tao
if (key == VkKeyScan('z'))
{
if (GetTickCount() - lastTimeThrow >= 500)
{
if (allowThrow)
{
Sound::getInstance()->play("Outta Apples", false, 1);
if (AppleCount < 1) return;
if (curApple > 2)
curApple = 0;
if (mCurrentState == PlayerState::ClimbingHori)
{
listApple.at(curApple)->SetPosition(D3DXVECTOR2(posX, posY));
listApple.at(curApple)->mReverse = !mCurrentReverse;
listApple.at(curApple)->SetState(AppleState::Flying);
curApple++;
AppleCount--;
return;
}
else
listApple.at(curApple)->SetPosition(D3DXVECTOR2(posX, posY - 50));
if (mCurrentState == PlayerState::Sit || mCurrentState == PlayerState::SitThrow)
listApple.at(curApple)->SetPosition(D3DXVECTOR2(posX, posY - 30));
listApple.at(curApple)->mReverse = mCurrentReverse;
listApple.at(curApple)->SetState(AppleState::Flying);
curApple++;
AppleCount--;
}
allowThrow = false;
lastTimeThrow = GetTickCount();
}
else return;
}
//if (key == VK_NUMPAD5) HPCount = 0;
}
void Player::OnKeyUp(int key)
{
if (key == VK_SPACE)
{
allowJump = true;
}
if (key == VkKeyScan('z'))
{
allowThrow = true;
}
}
void Player::Draw(D3DXVECTOR3 position, RECT sourceRect, D3DXVECTOR2 scale, D3DXVECTOR2 transform, float angle, D3DXVECTOR2 rotationCenter, D3DXCOLOR colorKey)
{
D3DXVECTOR2 trans = D3DXVECTOR2(GameGlobal::GetWidth() / 2 - mCamera->GetPosition().x,
GameGlobal::GetHeight() / 2 - mCamera->GetPosition().y);
if(mCurrentState!=PlayerState::ThrowCLimb)
mCurrentAnimation->GetSprite()->FlipVertical(mCurrentReverse);
else mCurrentAnimation->GetSprite()->FlipVertical(!mCurrentReverse);
mCurrentAnimation->SetPosition(this->GetPosition());
if (isAttacked)
{
if (Count_temp % 2 == 0)
{
if (mCamera)
mCurrentAnimation->Draw(D3DXVECTOR3(posX, posY, 0), sourceRect, scale, trans, angle, rotationCenter, colorKey);
}
Count_temp++;
if (Count_temp >16)
{
Count_temp = 0;
isAttacked = false;
}
}
else
mCurrentAnimation->Draw(D3DXVECTOR3(posX, posY, 0), sourceRect, scale, trans, angle, rotationCenter, colorKey);
for (int i = 0; i < listApple.size(); i++)
listApple.at(i)->Draw(listApple.at(i)->GetPosition(), sourceRect, scale, trans, angle, rotationCenter, colorKey);
}
void Player::SetState(PlayerState *newState)
{
delete this->mPlayerData->state;
this->mPlayerData->state = newState;
this->changeAnimation(newState->GetState());
mCurrentState = newState->GetState();
}
RECT Player::GetBound()
{
RECT rect;
if (mCurrentState == PlayerState::ClimbingHori)
{
rect.left = this->posX - mCurrentAnimation->GetSprite()->GetWidth() / 2;
rect.right = rect.left + mCurrentAnimation->GetSprite()->GetWidth();
rect.bottom = this->posY+ mCurrentAnimation->GetSprite()->GetHeight(); //Chú ý đoạn này
rect.top = this->posY;// + mCurrentAnimation->GetSprite()->GetHeight() / 2;
float cWidth = this->posX;
float cHeight = this->posY + mCurrentAnimation->GetSprite()->GetHeight() / 2;
SetCenter(D3DXVECTOR2(cWidth, cHeight));
return rect;
}
rect.left = this->posX - mCurrentAnimation->GetSprite()->GetWidth() / 2;
rect.right = rect.left + mCurrentAnimation->GetSprite()->GetWidth();
rect.top = this->posY - mCurrentAnimation->GetSprite()->GetHeight(); //Chú ý đoạn này
rect.bottom = this->posY;// + mCurrentAnimation->GetSprite()->GetHeight() / 2;
float cWidth = this->posX;
float cHeight= this->posY- mCurrentAnimation->GetSprite()->GetHeight()/2;
SetCenter(D3DXVECTOR2(cWidth, cHeight));
return rect;
}
void Player::changeAnimation(PlayerState::StateName state)
{
switch (state)
{
case PlayerState::JumpString:
mCurrentAnimation = mAnimationJumpString;
break;
case PlayerState::Stop:
mCurrentAnimation = mAnimationStopping;
break;
case PlayerState::Revive:
mCurrentAnimation = mAnimationRevive;
break;
case PlayerState::ClimbingHori:
mCurrentAnimation = mAnimationClimbHori;
break;
case PlayerState::ThrowCLimb:
mCurrentAnimation = mAnimationThrowClimb;
break;
case PlayerState::Fired:
mCurrentAnimation = mAnimationFired;
break;
case PlayerState::Running:
mCurrentAnimation = mAnimationRunning;
break;
case PlayerState::Standing:
mCurrentAnimation = mAnimationStanding;
break;
case PlayerState::Falling:
mCurrentAnimation = mAnimationFalling;
break;
case PlayerState::Jumping:
mCurrentAnimation = mAnimationJumping;
break;
case PlayerState::Throwing:
mCurrentAnimation = mAnimationThrowing;
break;
case PlayerState::Climbing:
mCurrentAnimation = mAnimationClimbing;
break;
case PlayerState::Fighting:
mCurrentAnimation = mAnimationFighting;
break;
case PlayerState::Sit:
mCurrentAnimation = mAnimationSiting;
break;
case PlayerState::SitFight:
mCurrentAnimation = mAnimationSitFight;
break;
case PlayerState::JumpThrow:
mCurrentAnimation = mAnimationJumpThrow;
break;
case PlayerState::SitThrow:
mCurrentAnimation = mAnimationSitThrow;
break;
case PlayerState::Bung:
mCurrentAnimation = mAnimationBung;
break;
}
this->width = mCurrentAnimation->GetSprite()->GetWidth();
this->height = mCurrentAnimation->GetSprite()->GetHeight();
}
Player::MoveDirection Player::getMoveDirection()
{
if (this->vx > 0)
{
return MoveDirection::MoveToRight;
}
else if (this->vx < 0)
{
return MoveDirection::MoveToLeft;
}
return MoveDirection::None;
}
PlayerState::StateName Player::getState()
{
return mCurrentState;
}
PlayerData* Player::GetCurrentPlayerData()
{
return mPlayerData;
}
void Player::SetCamera(Camera *camera)
{
this->mCamera = camera;
}
Animation* Player::GetCurrentAnimation()
{
return mCurrentAnimation;
}
bool Player::GetallowThrow()
{
return allowThrow;
}
void Player::SetallowThrow(bool flag)
{
allowThrow = flag;
}
void Player::OnNoCollisionWithBottom()
{
if (mCurrentState != PlayerState::Jumping && mCurrentState != PlayerState::Falling && mCurrentState != PlayerState::JumpThrow)
{
this->SetState(new PlayerFallingState(this->mPlayerData));
}
}
void Player::OnCollision(Entity *impactor, Entity::CollisionReturn data, Entity::SideCollisions side)
{
if ((impactor->Tag == Bowl || impactor->Tag == KnifeEnemy3) && this->getState() != PlayerState::Fired && this->getState() != PlayerState::Climbing && this->getState() != PlayerState::ClimbingHori)
{
this->SetState(new PlayerFiredState(this->mPlayerData));
}
if ((impactor->Tag == Bowl || impactor->Tag == KnifeEnemy3) && (this->getState() == PlayerState::Climbing || this->getState() == PlayerState::ClimbingHori))
{
isAttacked = true;
Sound::getInstance()->play("Aladdin Hurt", false, 1);
HPCount--;
}
if ((int)GetPosition().x > 2229 && (int)GetPosition().x < 2278 && ((int)LastPosition.x < 2229 || (int)LastPosition.x > 2278) && GetPosition().y>400)
{
if (CheckStair1)
CheckStair1 = false;
else CheckStair1 = true;
}
if ((int)GetPosition().x >= 2607 && (int)GetPosition().x <= 2658 && ((int)LastPosition.x < 2607 || (int)LastPosition.x > 2658) )
{
if (CheckStair2)
CheckStair2 = false;
else CheckStair2 = true;
}
if (CheckStair1 && (int) GetPosition().y >=600) CheckStair1 = false;
if ((impactor->Tag == stair2 && CheckStair2 == false) ||(impactor->Tag == stair1 && CheckStair1 == false)) return;
this->mPlayerData->state->OnCollision(impactor, side, data);
}
void Player::SetReverse(bool flag)
{
mCurrentReverse = flag;
}
bool Player::GetReverse()
{
return mCurrentReverse;
}
|
// Created on: 1992-09-28
// Created by: Remi GILET
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _GC_MakeConicalSurface_HeaderFile
#define _GC_MakeConicalSurface_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <GC_Root.hxx>
#include <Geom_ConicalSurface.hxx>
class gp_Ax2;
class gp_Cone;
class gp_Pnt;
//! This class implements the following algorithms used
//! to create a ConicalSurface from Geom.
//! * Create a ConicalSurface parallel to another and passing
//! through a point.
//! * Create a ConicalSurface parallel to another at a distance
//! <Dist>.
//! * Create a ConicalSurface by 4 points.
//! * Create a ConicalSurface by its axis and 2 points.
//! * Create a ConicalSurface by 2 points and 2 radius.
//! The local coordinate system of the ConicalSurface is defined
//! with an axis placement (see class ElementarySurface).
//!
//! The "ZAxis" is the symmetry axis of the ConicalSurface,
//! it gives the direction of increasing parametric value V.
//! The apex of the surface is on the negative side of this axis.
//!
//! The parametrization range is :
//! U [0, 2*PI], V ]-infinite, + infinite[
//!
//! The "XAxis" and the "YAxis" define the placement plane of the
//! surface (Z = 0, and parametric value V = 0) perpendicular to
//! the symmetry axis. The "XAxis" defines the origin of the
//! parameter U = 0. The trigonometric sense gives the positive
//! orientation for the parameter U.
//!
//! When you create a ConicalSurface the U and V directions of
//! parametrization are such that at each point of the surface the
//! normal is oriented towards the "outside region".
class GC_MakeConicalSurface : public GC_Root
{
public:
DEFINE_STANDARD_ALLOC
//! A2 defines the local coordinate system of the conical surface.
//! Ang is the conical surface semi-angle ]0, PI/2[.
//! Radius is the radius of the circle Viso in the placement plane
//! of the conical surface defined with "XAxis" and "YAxis".
//! The "ZDirection" of A2 defines the direction of the surface's
//! axis of symmetry.
//! If the location point of A2 is the apex of the surface
//! Radius = 0 .
//! At the creation the parametrization of the surface is defined
//! such that the normal Vector (N = D1U ^ D1V) is oriented towards
//! the "outside region" of the surface.
//! Status is "NegativeRadius" if Radius < 0.0 or "BadAngle" if
//! Ang < Resolution from gp or Ang >= PI/ - Resolution
Standard_EXPORT GC_MakeConicalSurface(const gp_Ax2& A2, const Standard_Real Ang, const Standard_Real Radius);
//! Creates a ConicalSurface from a non persistent Cone from package gp.
Standard_EXPORT GC_MakeConicalSurface(const gp_Cone& C);
//! Make a ConicalSurface from Geom <TheCone> passing through 3
//! Pnt <P1>,<P2>,<P3>.
//! Its axis is <P1P2> and the radius of its base is
//! the distance between <P3> and <P1P2>.
//! The distance between <P4> and <P1P2> is the radius of
//! the section passing through <P4>.
//! An error iss raised if <P1>,<P2>,<P3>,<P4> are
//! colinear or if <P3P4> is perpendicular to <P1P2> or
//! <P3P4> is colinear to <P1P2>.
Standard_EXPORT GC_MakeConicalSurface(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3, const gp_Pnt& P4);
//! Make a ConicalSurface with two points and two radius.
//! The axis of the solution is the line passing through
//! <P1> and <P2>.
//! <R1> is the radius of the section passing through <P1>
//! and <R2> the radius of the section passing through <P2>.
Standard_EXPORT GC_MakeConicalSurface(const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real R1, const Standard_Real R2);
//! Returns the constructed cone.
//! Exceptions
//! StdFail_NotDone if no cone is constructed.
Standard_EXPORT const Handle(Geom_ConicalSurface)& Value() const;
operator const Handle(Geom_ConicalSurface)& () const { return Value(); }
private:
Handle(Geom_ConicalSurface) TheCone;
};
#endif // _GC_MakeConicalSurface_HeaderFile
|
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#define PIC1 "Z:/Sai/Bangumi/paint/back2.jpg"
#define VID1 "D:/Cocoa/2016-1月番/OVA/【minori】EdenOP.mp4"
int First_Test_IMG_IMREAD(const std::string &path) {
cv::Mat img = cv::imread(path);
if (!img.empty()) {
cv::namedWindow("Test", cv::WINDOW_NORMAL);
cv::imshow("Test", img);
cv::waitKey(0);
cv::destroyWindow("Test");
}
else {
return -1;
}
return 0;
}
int First_Test_Video(const std::string &path) {
cv::namedWindow("tx", cv::WINDOW_NORMAL);
cv::VideoCapture cap;
cap.open(path);
cv::Mat frame;
for (;;)
{
cap >> frame;
if (frame.empty())break;
cv::imshow("tx", frame);
if (cv::waitKey(17) >= 0) {
cv::destroyAllWindows();
break;
}
}
return 0;
}
namespace First_Video_Bar {
//由于无法使用捕获造就的回调函数,只能声明成为全局变量
int g_slider_position = 0;
int g_run = 1, g_dontset = 0;
cv::VideoCapture cap;
void onTrackBarSlide(int pos, void * ) {
//std::cout << "OOOOO\n";
cap.set(cv::CAP_PROP_POS_FRAMES, pos);
if (!g_dontset) {
g_run = 1;
}
g_dontset = 0;
}
int First_Test_Video_Hard(const std::string &path) {
//int g_slider_position = 0;
//int g_run = 1, g_dontset = 0;
//cv::VideoCapture cap;
cv::namedWindow("t", cv::WINDOW_NORMAL);
cap.open(path);
int frames = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_COUNT));
int tmpw = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_WIDTH));
int tmph = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_HEIGHT));
std::cout << "Frams = " << frames
<< "\nw = " << tmpw
<< "\nh = " << tmph << std::endl;
//[注意]经测试,在OPENCV3中无法使用lambda或std::bind完成对回调函数的调用[只要捕获了其他变量]
//auto call = std::bind(onTrackBarSlide, std::placeholders::_1, std::placeholders::_2, std::ref(cap), std::ref(g_run), std::ref(g_dontset));
//cv::createTrackbar("position", "t", &g_slider_position, frames,
// call);
//cv::createTrackbar("position", "t", &g_slider_position, frames,
// [](int pos, void *) {
// //ok
//});
cv::createTrackbar("position", "t", &g_slider_position, frames, onTrackBarSlide);
cv::Mat frame;
for (;;)
{
if (g_run != 0) {
cap >> frame;
if(frame.empty())
break;
int current_pos = (int)cap.get(cv::CAP_PROP_POS_FRAMES);
g_dontset = 1;
cv::setTrackbarPos("position", "t", current_pos);
cv::imshow("t", frame);
g_run -= 1;
}
char c = (char)cv::waitKey(10);
if (c == 's')
{
g_run = 1;
std::cout << "Single Step, run = " << g_run << std::endl;
}
if (c == 'r') {
g_run = -1;
std::cout << "Run mode, run = " << g_run << std::endl;
}
if (c == 27) {
break;
}
}
cv::destroyWindow("t");
return 0;
}
}
int Smooth_Pic_Test(const std::string & path) {
cv::Mat in_mat;
cv::Mat out_mat;
in_mat = cv::imread(path, -1);
cv::namedWindow("in", cv::WINDOW_AUTOSIZE);
cv::namedWindow("out", cv::WINDOW_AUTOSIZE);
cv::GaussianBlur(in_mat, out_mat, cv::Size(5, 5), 3, 3);
cv::imshow("in", in_mat);
cv::imshow("out", out_mat);
cv::waitKey(0);
return 0;
}
int main()
{
//First_Test_IMG_IMREAD(PIC1);
//First_Test_Video(VID1);
//First_Video_Bar::First_Test_Video_Hard(VID1);
Smooth_Pic_Test(PIC1);
system("pause");
}
|
//
// Created by root on 12/29/19.
//
#ifndef CPPSSWIMPL_CPPINVOKEPYTHON_HH
#define CPPSSWIMPL_CPPINVOKEPYTHON_HH
class cppinvokepython {
};
#endif //CPPSSWIMPL_CPPINVOKEPYTHON_HH
|
#pragma once
void Dijkstra(std::vector<std::vector<unsigned>> const &matrix, unsigned const &startNode, std::ofstream &output);
void FindNextEdge(std::vector<unsigned> const &distance, std::vector<bool> &visited, unsigned ¤tNode);
void PrintCurrentState(std::vector<unsigned> const &distance, std::ofstream &output);
void CalculateNewWeight(std::vector<std::vector<unsigned>> const &matrix, std::vector<unsigned> &distance,
std::vector<bool> const &visited, std::vector<unsigned> &parents, const unsigned ¤tNode, std::ofstream &output);
void ShowPath(std::vector<unsigned> &parents, unsigned const &node, unsigned const &startNode, std::ofstream &output);
|
#include "Langevin.h"
#include "random.h"
#include "predefine.h"
#include "matrix_elements.h"
double const tiny = 1e-10;
double qhat_small_angle_LOpQCD(int pid, double E, double M, double T){
double CR = (pid==21) ? CA : CF;
double mD2 = t_channel_mD2->get_mD2(T);
double Q2cut = std::max(std::min(cut*mD2, 6*E*T),mD2);
return alpha_s(Q2cut, T) * CR * T * mD2 * std::log(1.+Q2cut/mD2);
}
double qhat_L_small_angle_LOpQCD(int pid, double E, double M, double T){
double CR = (pid==21) ? CA : CF;
double mD2 = t_channel_mD2->get_mD2(T);
double Q2cut = std::max(std::min(cut*mD2, 6*E*T),mD2);
return alpha_s(Q2cut, T) * CR * T * .5*mD2 * std::log(1.+Q2cut/mD2);
}
double qhat(int pid, double E, double M, double T){
return qhat_small_angle_LOpQCD(pid, E, M, T);
}
double qhat_L(int pid, double E, double M, double T){
return qhat_L_small_angle_LOpQCD(pid, E, M, T);
}
double dqhat_L_dp2(int pid, double E, double M, double T){
double p2 = E*E - M*M + tiny;
double dp2 = p2*.05;
double Eprime = std::sqrt(E*E + dp2);
return (qhat_L(pid, Eprime, M, T) - qhat_L(pid, E, M, T) ) /dp2;
}
void Ito_update(int pid, double dt_lab, double M, double T,
std::vector<double> v, const fourvec & pIn, fourvec & pOut, bool is_virtual){
// Boost pIn to medium frame
auto pIn_cell = pIn.boost_to(v[0], v[1], v[2]);
// Boost dt to medium frame
double dt = dt_lab*pIn_cell.t()/pIn.t();
// imaging rotating to a frame where pIn lies on z-axis
double E0 = pIn_cell.t();
double p0 = std::sqrt(E0*E0 - M*M + 1e-6);
double kt = qhat(pid, E0, M, T)/2.;
double kl = qhat_L(pid, E0, M, T);
double Ed = std::max(E0, 3.*T);
double drag = kl/(2.*Ed*T);
double damp = std::max(1.-drag*dt, 0.);
double Ct = std::sqrt(kt*dt);
double Cl = std::sqrt(kl*dt);
pOut.a[1] = Ct * Srandom::white_noise(Srandom::gen);
pOut.a[2] = Ct * Srandom::white_noise(Srandom::gen);
pOut.a[3] = p0 * damp + Cl * Srandom::white_noise(Srandom::gen);
pOut.a[0] = std::sqrt(M*M + pOut.pabs2() );
// rotate back to the original frame
pOut = pOut.rotate_back(pIn_cell);
// boost back to lab frame
pOut = pOut.boost_back(v[0], v[1], v[2]);
}
|
#include <Timer.h>
//#include <mcp_can.h>
//#include <mcp_can_dfs.h>
/*
* TODO:
* CASEY - optimize libraries so THEY AREN'T SO BIG DEAR JESUS THE SIZE OF THOSE
*
*/
#include <Bridge.h>
#include <Wire.h>
#include <YunServer.h>
#include <YunClient.h>
// For IMU
#include <I2Cdev.h>
#include <ADXL345.h>
#include <HMC5883L.h>
//#include <L3G4200D.h>
// For GPS
//#include <Adafruit_GPS.h>
//#include <Casey_GPS.h>
//#include <SoftwareSerial.h>
// For cam pan/tilt
#include <Adafruit_PWMServoDriver.h>
// For weather temp/pressure sensor
#include <BMP085.h>
#include "gps.h"
#include "i2c.h"
#include "imu.h"
#include "pwm_board.h"
#include "avionics_temp.h"
#include "thermistor.h"
#include "volt_amp.h"
#include "weather.h"
YunServer server(5555);
// Timing for telemetry data
Timer timer;
YunClient* cur_client = NULL;
void setup()
{
//Serial.begin(115200);
//while( !Serial ){ ; }
Bridge.begin();
// Need this for communication with uno and IMU
Wire.begin();
init_imu();
init_pwm_board_cam();
init_weather();
amp_init();
timer.every(250, send_250ms_telemetry);
timer.every(500, send_500ms_telemetry);
timer.every(2000, send_2000ms_telemetry);
server.listenOnLocalhost();
server.begin();
stop_rover();
//Serial.println("Starting rover...");
}
void loop() {
timer.update();
// Get clients coming from server
YunClient client = server.accept();
// There is a new client
if (client) {
// Tiny timeout
client.setTimeout(5);
//Serial.println("Client connected!");
cur_client = &client;
while(client.connected()){
client_loop(client);
}
// Stop rover if we get disconnected
stop_rover();
// Close connection and free resources.
client.stop();
cur_client = NULL;
} else {
//Serial.println("no client connected, retrying");
}
// Delay for the battery, for the debug too. Doesn't affect the response time of the Arduino. (Check if there is another client each second)
delay(50);
}
void client_loop(YunClient& client)
{
timer.update();
char cmd_id = client.read();
if (cmd_id != -1) {
if (cmd_id == 'A') {
int l = client.parseInt();
byte i2c_motor_msg = i2c_left;
if (l > 0) {
i2c_motor_msg += i2c_dir_left;
}
send_i2c_message(byte(abs(l)), i2c_motor_msg, 2);
} else if (cmd_id == 'B') {
int r = client.parseInt();
byte i2c_motor_msg = i2c_right;
if (r > 0) {
i2c_motor_msg += i2c_dir_right;
}
send_i2c_message(byte(abs(r)), i2c_motor_msg, 2);
} else if (cmd_id == 'H') {
int l = client.parseInt();
client.read(); // Skip '|'
int r = client.parseInt();
byte l_i2c_motor_msg = i2c_left;
if (l > 0) {
l_i2c_motor_msg |= i2c_dir_left;
}
byte r_i2c_motor_msg = i2c_right;
if (r > 0) {
r_i2c_motor_msg |= i2c_dir_right;
}
send_i2c_message(byte(abs(l)), l_i2c_motor_msg, 2);
send_i2c_message(byte(abs(r)), r_i2c_motor_msg, 2);
} else if (cmd_id == 'C') {
int f_pan = client.parseInt();
set_cam_pan(f_pan);
} else if (cmd_id == 'D') {
int f_tilt = client.parseInt();
set_cam_tilt(f_tilt);
} else if (cmd_id == 'E') {
// SADL
int sadl = client.parseInt();
byte i2c_motor_msg = i2c_sadl;
if (sadl > 0) {
i2c_motor_msg += i2c_dir;
}
send_i2c_message(byte(abs(sadl)), i2c_motor_msg, 2);
} else if (cmd_id == 'F') {
// BLADE
int blade = client.parseInt();
//set_blade_power(blade);
/*byte i2c_motor_msg = i2c_blade;
if (blade > 0) {
i2c_motor_msg += i2c_dir;
}
send_i2c_message(byte(abs(blade)), i2c_motor_msg, 2);*/
} else if (cmd_id == 'G') {
send_i2c_message(byte(0), i2c_brake, 2);
}
client.read(); // Skip terminating '|'
}
}
void stop_rover()
{
send_i2c_message(0, i2c_left, 2);
send_i2c_message(0, i2c_right, 2);
send_i2c_message(0, i2c_sadl, 2);
send_i2c_message(0, i2c_blade, 2);
}
void send_250ms_telemetry()
{
static char buf[256];
size_t len = 0;
if (cur_client) {
len += get_va_data(buf+len);
len += get_imu_data(buf+len);
len += get_avionics_temp_data(buf+len);
cur_client->print(buf);
}
}
void send_500ms_telemetry()
{
if (cur_client) {
String thermistor = get_thermistor_data();
String weather = get_weather_data();
String amps = get_uno_amps();
cur_client->print(thermistor+"|"+weather+"|"+amps+"|");
}
}
void send_2000ms_telemetry()
{
if (cur_client) {
String gps = get_gps();
cur_client->print(gps+"|");
}
}
|
#include "MySolution1.h"
#include <string>
#include <iostream>
#include <algorithm>
#include <assert.h>
#include <vector>
using namespace std;
int StupidRSQ(vector <int> arr, int begin, int end){
int result = 0;
for (int i = begin; i <= end; i++){
result += arr[i];
}
return result;
}
void StupidNextPermutation(vector<int> &arr, int begin, int end){
int suffix = 1;
int i = end;
while (arr[i] <= arr[i - 1]){
suffix++;
i--;
if (i < 0)
break;
}
if (suffix >= end - begin + 1){
int k = begin;
for (int i = 0; i < (end - k + 1) / 2; i++){
swap(arr[k + i], arr[end - i]);
}
}
else{
i--;
int ToChange = i;
int j = ToChange + 1;
while (arr[j] > arr[ToChange]){
j++;
if (j > end)
break;
}
j--;
swap(arr[ToChange], arr[j]);
for (int l = 0; l < (end - ToChange) / 2; l++){
swap(arr[ToChange + 1 + l], arr[end - l]);
}
}
//std::next_permutation((arr.begin() + begin), (arr.begin() + end + 1));
}
bool TreeVsArray(item tr, vector <int> arr){
assert(tr->c == arr.size());
for (int i = 0; i < arr.size(); i++){
if (tr->Find(i)->data != arr[i]){
return false;
}
}
return true;
}
|
/*
* Copyright 2016 Freeman Zhang <zhanggyb@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SKLAND_GUI_POPUP_SHELL_SURFACE_HPP_
#define SKLAND_GUI_POPUP_SHELL_SURFACE_HPP_
#include "../core/margin.hpp"
#include "../wayland/xdg-popup.hpp"
#include "../wayland/xdg-positioner.hpp"
namespace skland {
class Surface;
class AbstractEventHandler;
class ShellSurface;
/**
* @ingroup gui
* @brief Xdg popup shell surface
*/
class PopupShellSurface {
friend class ShellSurface;
PopupShellSurface() = delete;
PopupShellSurface(const PopupShellSurface &) = delete;
PopupShellSurface &operator=(const PopupShellSurface &) = delete;
public:
static Surface *Create(ShellSurface *parent, AbstractEventHandler *view, const Margin &margin = Margin());
PopupShellSurface(AbstractEventHandler *view, const Margin &margin = Margin());
private:
PopupShellSurface(ShellSurface *shell_surface);
~PopupShellSurface();
ShellSurface *shell_surface_;
wayland::XdgPopup xdg_popup_;
wayland::XdgPositioner xdg_positioner_;
};
}
#endif // SKLAND_GUI_POPUP_SHELL_SURFACE_HPP_
|
#include <iostream>
#include <vector>
using namespace std;
struct Componentes
{
float levadura , // KG
malta , // KG
agua , // litros
cebada , // KG
lupulos ; // KG
} ;
struct DatosMes
{
Componentes s1 , // semana 1
s2 , // semana 2
s3 , // semana 3
s4 ; // semana 4
} ;
int menu( string ) ;
DatosMes soliDatos( vector<string> ) ;
Componentes datoSemanal( Componentes , vector<string> ) ;
void mostrarDatosMes( Componentes , vector<string> ) ;
int main()
{
DatosMes meses[12] ;
vector<string> nombres = { "levadura" , "malta" , "agua" , "cebada" , "lupulo" } ;
vector<float> gastos ;
string msj ;
int op = 1 ;
while( op != 0 )
{
msj = "0.- Salir.\n"
"1.- Ingresar datos.\n"
"2.- Litros de agua consumidos.\n"
"3.- Promedio de los componentes.\n"
"4.- Gastos por componente.\n"
"5.- Componente que mas se utilizo.\n"
"op: ";
op = menu( msj ) ; cout << endl ;
switch( op )
{
case 1 : msj = "Ingrese el numero del mes: " ; op = menu( msj ) ;
meses[op-1] = soliDatos( nombres ) ; break ;
case 2 : break ;
case 3 : break ;
case 4 : break ;
case 5 : break ;
default: cout << "Saliendo del programa." << endl ; break ;
}
}
return 0 ;
} // fin main
int menu( string msj )
{
int valor ;
cout << msj ; cin >> valor ;
return valor ;
} // fin menu
DatosMes soliDatos( vector<string> nombres )
{
DatosMes semanaMes ;
vector<Componentes> semanas = { semanaMes.s1 , semanaMes.s2 , semanaMes.s3 , semanaMes.s4 } ;
cout << "Ingrese los datos solicitados." << endl << endl ;
for( int i = 0 ; i < semanas.size() ; i++ )
{
cout << "Datos de la semana " << i+1 << endl ;
semanas[i] = datoSemanal( semanas.at(i) , nombres ) ;
cout << endl ;
}
cout << "Mostrar los datos del mes." << endl ;
for( int i = 0 ; i < semanas.size() ; i++ )
{
mostrarDatosMes( semanas.at(i) , nombres ) ;
}
semanaMes.s1 = semanas.at(0) ;
semanaMes.s2 = semanas.at(1) ;
semanaMes.s3 = semanas.at(2) ;
semanaMes.s4 = semanas.at(3) ;
return semanaMes ;
} // fin soliDatos
Componentes datoSemanal( Componentes semana , vector<string> nombres )
{
cout << nombres.at(0) << ": " ; cin >> semana.levadura ;
cout << nombres.at(1) << ": " ; cin >> semana.malta ;
cout << nombres.at(2) << ": " ; cin >> semana.agua ;
cout << nombres.at(3) << ": " ; cin >> semana.cebada ;
cout << nombres.at(4) << ": " ; cin >> semana.lupulos ;
return semana ;
} // fin datoSemanal
void mostrarDatosMes( Componentes semana , vector<string> nombres )
{
cout << nombres.at(0) << ": " ; cout << semana.levadura << endl ;
cout << nombres.at(1) << ": " ; cout << semana.malta << endl ;
cout << nombres.at(2) << ": " ; cout << semana.agua << endl ;
cout << nombres.at(3) << ": " ; cout << semana.cebada << endl ;
cout << nombres.at(4) << ": " ; cout << semana.lupulos << endl ;
} // fin mostrarDatosMes
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* Copyright (C) 1995-2012 Opera Software AS. All rights reserved.
*
* This file is part of the Opera web browser. It may not be distributed
* under any circumstances.
*
* @author Cezary Kulakowski (ckulakowski)
*/
#ifndef OP_INDICATOR_BUTTON_H
#define OP_INDICATOR_BUTTON_H
#include "modules/widgets/OpButton.h"
class DesktopWindow;
/**
* This class represents indicator which informs user about state of
* permissions for camera and geolocation set for the page. It also informs
* user if geolocation or camera is currently in use. Indicator consists of three
* icons: geolocation, camera and separator. Geolocation and camera icons can be
* in one of four states:
* 1. disabled (icon is hidden) - permission for corresponding device is not granted
* 2. enabled and active (black icon) - permission is granted and device is currently in use
* 3. enabled and inactive (grey icon) - permission is granted but device is not in use
* 4. enabled and inverted (white icon) - it is used only in tab bar stack button
*
* Indicators are located in following places:
*
* 1. badge (for current page)
* 2. Tab button (for background tabs)
* 3. Tab stack button (for stacked, background tabs)
*
* Note: in tab button and tab stack button we don't display inactive icons.
* In addition in tab stack button we use inverted (white) icons.
* For details see PGDSK-1013.
*/
class OpIndicatorButton : public OpButton
{
public:
/**
* Values of this enum represent icons types which are the part of
* the indicator (see class description).
*/
enum IndicatorType
{
CAMERA = 1,
GEOLOCATION,
SEPARATOR
};
/**
* Values of this enum represent state of the indicator icons. Every icon
* (camera/geolocation/separator) can be in one of the three states:
* - ACTIVE - black icon
* - INACTIVE - grey icon
* - INVERTED - white icon
*/
enum IconState
{
ACTIVE,
INACTIVE,
INVERTED
};
/**
* Values of this enum determines position of vertical separator in relation
* to other icons (camera and/or geolocation).
*/
enum SeparatorPosition
{
LEFT,
RIGHT
};
OpIndicatorButton(DesktopWindow* desktop_window, SeparatorPosition pos = LEFT)
: m_desktop_window(desktop_window)
, m_camera_button(NULL)
, m_geolocation_button(NULL)
, m_separator_button(NULL)
, m_indicator_type(0)
, m_is_camera_active(false)
, m_is_geolocation_active(false)
, m_show_separator(true)
, m_separator_position(pos)
{}
OP_STATUS Init(const char* border_skin = "Toolbar Button Skin");
// OpWidget
virtual void OnLayout();
virtual void OnShow(BOOL show);
INT32 GetPreferredWidth();
INT32 GetPreferredHeight();
/**
* Sets state for given indicator part (camera/geolocation/separator).
* @param type icon type for which state should be changed
* @param state new icon state
*/
void SetIconState(IndicatorType type, IconState state);
bool IsCameraActive() const { return m_is_camera_active; }
bool IsGeolocationActive() const { return m_is_geolocation_active; }
/**
* Adds (enables) given indicator icon
* @param type type of the icon which should be enabled
*/
void AddIndicator(IndicatorType type) { UpdateButtons(type, true); }
/** Removes (disables) given indicator icon
* @param type type of the icon which should be disabled
*/
void RemoveIndicator(IndicatorType type) { UpdateButtons(type, false); }
/** Sets indicator type. Parameter @a type is a sum of states
* of all device icons. First bit represents state (enabled/disabled)
* of camera icon and second bit represents state of gelocation icon.
*/
void SetIndicatorType(short type);
/** Returns indicator type which is a sum of states of all device icons.
* First bit represents state (enabled/disabled) of camera icon
* and second bit represents state of gelocation icon.
*/
short GetIndicatorType() { return m_indicator_type; }
/** Sets if separator located on right or left side of indicator icons
* should be displayed.
*/
void ShowSeparator(bool show_separator) { m_show_separator = show_separator; }
private:
void UpdateButtons(IndicatorType type, bool set);
void LayoutButton(OpButton* button, OpRect& orig_rect);
DesktopWindow* m_desktop_window;
OpButton* m_camera_button;
OpButton* m_geolocation_button;
OpButton* m_separator_button;
short m_indicator_type;
bool m_is_camera_active;
bool m_is_geolocation_active;
bool m_show_separator;
SeparatorPosition m_separator_position;
};
#endif // OP_INDICATOR_BUTTON_H
|
#include <cstdio>
int main(){
int t1, t2, n, m, z;
scanf("%d %d %d %d %d", &t1, &t2, &n, &m, &z);
printf("%d\n", z * (t1 * n + t2 * m));
return 0;
}
|
// Created on: 1993-01-09
// Created by: CKY / Contract Toubro-Larsen ( SIVA )
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _IGESSolid_Ellipsoid_HeaderFile
#define _IGESSolid_Ellipsoid_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <gp_XYZ.hxx>
#include <IGESData_IGESEntity.hxx>
class gp_Pnt;
class gp_Dir;
class IGESSolid_Ellipsoid;
DEFINE_STANDARD_HANDLE(IGESSolid_Ellipsoid, IGESData_IGESEntity)
//! defines Ellipsoid, Type <168> Form Number <0>
//! in package IGESSolid
//! The ellipsoid is a solid bounded by the surface defined
//! by:
//! X^2 Y^2 Z^2
//! ----- + ----- + ----- = 1
//! LX^2 LY^2 LZ^2
class IGESSolid_Ellipsoid : public IGESData_IGESEntity
{
public:
Standard_EXPORT IGESSolid_Ellipsoid();
//! This method is used to set the fields of the class
//! Ellipsoid
//! - aSize : Lengths in the local X,Y,Z directions
//! - aCenter : Center point of ellipsoid (default (0,0,0))
//! - anXAxis : Unit vector defining local X-axis
//! default (1,0,0)
//! - anZAxis : Unit vector defining local Z-axis
//! default (0,0,1)
Standard_EXPORT void Init (const gp_XYZ& aSize, const gp_XYZ& aCenter, const gp_XYZ& anXAxis, const gp_XYZ& anZAxis);
//! returns the size
Standard_EXPORT gp_XYZ Size() const;
//! returns the length in the local X-direction
Standard_EXPORT Standard_Real XLength() const;
//! returns the length in the local Y-direction
Standard_EXPORT Standard_Real YLength() const;
//! returns the length in the local Z-direction
Standard_EXPORT Standard_Real ZLength() const;
//! returns the center of the ellipsoid
Standard_EXPORT gp_Pnt Center() const;
//! returns the center of the ellipsoid after applying
//! TransformationMatrix
Standard_EXPORT gp_Pnt TransformedCenter() const;
//! returns the vector corresponding to the local X-direction
Standard_EXPORT gp_Dir XAxis() const;
//! returns the vector corresponding to the local X-direction
//! after applying TransformationMatrix
Standard_EXPORT gp_Dir TransformedXAxis() const;
//! returns the vector corresponding to the local Y-direction
//! which is got by taking cross product of ZAxis and XAxis
Standard_EXPORT gp_Dir YAxis() const;
//! returns the vector corresponding to the local Y-direction
//! (which is got by taking cross product of ZAxis and XAxis)
//! after applying TransformationMatrix
Standard_EXPORT gp_Dir TransformedYAxis() const;
//! returns the vector corresponding to the local Z-direction
Standard_EXPORT gp_Dir ZAxis() const;
//! returns the vector corresponding to the local Z-direction
//! after applying TransformationMatrix
Standard_EXPORT gp_Dir TransformedZAxis() const;
DEFINE_STANDARD_RTTIEXT(IGESSolid_Ellipsoid,IGESData_IGESEntity)
protected:
private:
gp_XYZ theSize;
gp_XYZ theCenter;
gp_XYZ theXAxis;
gp_XYZ theZAxis;
};
#endif // _IGESSolid_Ellipsoid_HeaderFile
|
#pragma once
#include <QGraphicsPixmapItem>
class Window;
#include "Connection.h"
#include "WallItem.h"
class Window :public WallItem
{
private:
QImage img;
public:
Window(Connection* c1, Connection* c2);
double calculateRotation();
void deatach() override;
void updatePositions() override;
Connection** getConnections() override;
~Window();
};
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
long n,q;
cin>>n>>q;
vector<ll> a(n);
for(int i=0;i<n;i++) {
cin>>a[i];
}
while(q--) {
long x,l,r;
cin>>x>>l>>r;
if(x==1) {
a[l-1]=r;
} else {
ll peri=0;
if((r-l+1)<3) {
cout<<0<<"\n";
} else {
vector<ll> v;
copy(a.begin()+(l-1),a.begin()+r,back_inserter(v));
sort(v.begin(),v.end());
for(int i=v.size()-1;i>=2;i--) {
// cout<<v[i]<<" "<<v[i-1]<<" "<<v[i-2]<<" ";
if(v[i]<(v[i-1]+v[i-2])) {
peri=v[i]+v[i-1]+v[i-2];
break;
}
}
cout<<peri<<"\n";
}
}
}
return 0;
}
|
#include "WinCommon.h"
#include "DXCommon.h"
#include "MyTeapot.h"
MyTeapot::MyTeapot(void)
{
m_vPos = D3DXVECTOR3(-3,1,0);
m_vRot = D3DXVECTOR3(0,0,0);
m_vScale = D3DXVECTOR3(1,1,1);
D3DXMatrixIdentity(&m_mScale);
D3DXMatrixIdentity(&m_mRot);
D3DXMatrixIdentity(&m_mTrans);
}
MyTeapot::~MyTeapot(void)
{
}
void MyTeapot::InitTeapot( void )
{
D3DXCreateTeapot(g_pDevice, &m_pTeapot, NULL);
ZeroMemory(&m_Mtrl, sizeof(m_Mtrl));
m_Mtrl.Diffuse = D3DXCOLOR(1,1,1,0.5f);
m_Mtrl.Ambient = D3DXCOLOR(1,1,1,1);
m_Mtrl.Specular = D3DXCOLOR(1,1,1,1);
m_Mtrl.Power = 30.0f;
if( FAILED(D3DXCreateTextureFromFile(g_pDevice, "./Data/SphereMap/spheremap.bmp", &m_envTexture)) )
{
MessageBox(NULL, "Env Texture load fail", "error", MB_OK);
}
}
void MyTeapot::UpdateTeapot( float dTime )
{
static float angle = 0.0f;
angle += 0.5f * dTime;
D3DXMatrixRotationY(&m_mRot, angle);
D3DXMatrixTranslation(&m_mTrans, m_vPos.x, m_vPos.y, m_vPos.z);
m_mTM = m_mScale * m_mRot * m_mTrans;
}
void MyTeapot::RenderTeapot( int LState )
{
g_pDevice->SetTransform(D3DTS_WORLD, &m_mTM);
g_pDevice->SetMaterial(&m_Mtrl);
// 환경광 그리기 //
g_pDevice->SetRenderState(D3DRS_LIGHTING, true);
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
g_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
g_pDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL);
g_pDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
D3DXMATRIX mSphereTM;
mSphereTM._11 = 0.5f; mSphereTM._12 = 0.0f; mSphereTM._13 = 0.0f; mSphereTM._14 = 0.0f;
mSphereTM._21 = 0.0f; mSphereTM._22 =-0.5f; mSphereTM._23 = 0.0f; mSphereTM._24 = 0.0f;
mSphereTM._31 = 0.0f; mSphereTM._32 = 0.0f; mSphereTM._33 = 1.0f; mSphereTM._34 = 0.0f;
mSphereTM._41 = 0.5f; mSphereTM._42 = 0.5f; mSphereTM._43 = 0.0f; mSphereTM._44 = 1.0f;
g_pDevice->SetTransform( D3DTS_TEXTURE0, &mSphereTM );
g_pDevice->SetTexture(0, g_bWireFrame ? NULL : m_envTexture);
m_pTeapot->DrawSubset(0);
g_pDevice->SetRenderState(D3DRS_LIGHTING, false);
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
g_pDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU);
g_pDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
// 광원만 그리기 //
g_pDevice->SetRenderState(D3DRS_LIGHTING, true);
if( LState == 3)
g_pDevice->SetRenderState(D3DRS_SPECULARENABLE, false);
else
g_pDevice->SetRenderState(D3DRS_SPECULARENABLE, true);
g_pDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
g_pDevice->SetTexture(0, NULL);
g_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
g_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_CONSTANT);
g_pDevice->SetTextureStageState(0, D3DTSS_CONSTANT, D3DXCOLOR(0,0,0,1));
g_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTALPHA);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CONSTANT);
m_pTeapot->DrawSubset(0);
g_pDevice->SetRenderState(D3DRS_LIGHTING, false);
g_pDevice->SetRenderState(D3DRS_SPECULARENABLE, false);
g_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
g_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_CURRENT);
g_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
g_pDevice->SetTexture(0, NULL);
}
void MyTeapot::ReleaseTeapot( void )
{
SAFE_RELEASE(m_pTeapot);
SAFE_RELEASE(m_envTexture);
}
|
//
// Created by silvman on 3/2/19.
//
#include <string>
#include <unordered_map>
#include <iomanip>
#include "HTTPUtility.h"
std::string eeskorka::utility::URLDecode(const std::string &uri) {
std::string ret;
char rune = 0;
unsigned coded = 0;
size_t len = uri.length();
for (unsigned i = 0; i < len; i++) {
if (uri[i] != '%') {
if (uri[i] == '+')
ret += ' ';
else
ret += uri[i];
} else {
sscanf(uri.substr(i + 1, 2).c_str(), "%x", &coded);
rune = static_cast<char>(coded);
ret += rune;
i = i + 2;
}
}
return ret;
}
std::string eeskorka::utility::RFC1123Time(time_t time) {
char buffer[80];
struct tm *timeinfo;
timeinfo = gmtime(&time);
strftime(buffer, 80, "%a, %d %b %Y %H:%M:%S GMT", timeinfo);
return buffer;
}
std::string eeskorka::utility::getContentType(const fs::path &path) {
static std::unordered_map<std::string, std::string> mime = {
{".html", "text/html"},
{".css", "text/css"},
{".js", "text/javascript"},
{".jpg", "image/jpeg"},
{".jpeg", "image/jpeg"},
{".png", "image/png"},
{".gif", "image/gif"},
{".swf", "application/x-shockwave-flash"}
};
std::string ext = path.extension();
if (mime.find(ext) != mime.end()) {
return mime[ext];
}
return "text/plain";
}
eeskorka::serverConfig eeskorka::utility::readConfig(const std::filesystem::path &path) {
if (!fs::exists(path)) {
throw std::runtime_error(fmt::format("file not exists: {}", path.string()));
}
serverConfig config;
std::ifstream f(path);
std::string buf;
std::regex re("([^ \t\r\n\v\f]+[A-Za-z0-9!\"#$%&'()*+,./:;<=>?@\\^_`{|}~-]*)");
while (!f.eof()) {
std::getline(f, buf);
auto commentIt = std::find(buf.begin(), buf.end(), '#');
for (std::sregex_token_iterator i{buf.begin(), commentIt, re, 0}, end; i != end; ++i) {
std::string token{*i};
if (token == "cpu_limit") {
++i;
config.workers = std::atoi((*i).str().c_str());
if (config.workers < 1) {
throw std::runtime_error(
fmt::format("config parse failed: cpu_limit == {} (must be at least 1)", config.workers));
}
break;
}
if (token == "thread_limit") {
++i;
config.numThreads = std::atoi((*i).str().c_str());
if (config.workers < 1) {
throw std::runtime_error(
fmt::format("config parse failed: thread_limit == {} (must be at least 1)",
config.workers));
}
break;
}
if (token == "document_root") {
++i;
config.rootDir = (*i).str();
if (!fs::exists(config.rootDir)) {
throw std::runtime_error(
fmt::format("config parse failed: {} does not exists", config.rootDir));
}
if (!fs::is_directory(config.rootDir)) {
throw std::runtime_error(
fmt::format("config parse failed: {} is not a directory", config.rootDir));
}
break;
}
if (token == "buffer_size") {
++i;
config.bufferSize = static_cast<size_t>(std::atoi((*i).str().c_str()));
if (config.bufferSize < 32) {
throw std::runtime_error(
fmt::format("config parse failed: buffer_size must be greater than 32"));
}
}
if (token == "port") {
++i;
config.port = std::atoi((*i).str().c_str());
if (config.port < 0 || config.port >= 65536) {
throw std::runtime_error(
fmt::format("config parse failed: port must be 0 <= {} < 65536", config.port));
}
}
if (token == "max_clients") {
++i;
config.maxClients = std::atoi((*i).str().c_str());
if (config.maxClients < config.workers) {
throw std::runtime_error(
fmt::format(
"config parse failed: max_clients ({}) must be greather "
"or equeal to max_cores ({})",
config.maxClients, config.workers));
}
}
}
}
return config;
}
std::string eeskorka::utility::URLEncode(const std::string &uri) {
std::string enc;
char bufHex[10];
for (const auto &rune : uri) {
if (rune == ' ') {
enc += '+';
} else if (isalnum(rune) || rune == '-' || rune == '_' || rune == '.' || rune == '~' || rune == '/') {
enc += rune;
} else {
enc += fmt::format("%{:02X}", rune);
}
}
return enc;
}
|
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 1000111;
vector< pair<int, int> > a[N];
vector< pair<int, int> > b[N];
vector< pair<int, int> > cur;
int main() {
int m, n, w;
int it = 0;
while (true) {
++it;
scanf("%d%d%d", &m, &n, &w);
if (m == 0 && n == 0 && w == 0) break;
for (int i = 0; i < m; ++i) {
a[i].clear();
b[i].clear();
}
ll sq = ll(n) * ll(m);
ll wallssq = 0;
ll goodsq = 0;
while (w--) {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
wallssq += ll(x2 - x1 + 1) * ll(y2 - y1 + 1);
a[y1].push_back(make_pair(x1, x2));
}
for (int i = 0; i < m; ++i)
sort(a[i].begin(), a[i].end(), std::greater< pair<int, int> >());
if (a[m - 1].size() > 0) {
if (a[m - 1][0].second == n - 1) {
} else {
b[m - 1].push_back(make_pair(a[m - 1][0].second + 1, n - 1));
}
} else {
b[m - 1].push_back(make_pair(0, n - 1));
}
for (int y = m - 1; y >= 0; --y) {
if (b[y].empty()) {
break;
}
for (int i = 0; i < b[y].size(); ++i) goodsq += b[y][i].second - b[y][i].first + 1;
if (y == 0) break;
cur.clear();
{
int to = n - 1;
for (int i = 0; i < a[y - 1].size(); ++i) {
int from = a[y - 1][i].second + 1;
if (from <= to) {
cur.push_back(make_pair(from, to));
}
to = a[y - 1][i].first - 1;
}
int from = 0;
if (from <= to) {
cur.push_back(make_pair(from, to));
}
}
int pointer = 0;
for (int i = 0; i < cur.size(); ++i) {
while (pointer < b[y].size() && b[y][pointer].first > cur[i].second) ++pointer;
if (pointer < b[y].size() && b[y][pointer].second >= cur[i].first) {
b[y - 1].push_back( make_pair(cur[i].first, min(cur[i].second, b[y][pointer].second)) );
}
}
}
printf("Case %d: %lld\n", it, sq - wallssq - goodsq);
}
return 0;
}
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* Copyright (C) 1995-2011 Opera Software AS. All rights reserved.
*
* This file is part of the Opera web browser. It may not be distributed
* under any circumstances.
*/
#include "core/pch.h"
#include "adjunct/quick/sync/view/SyncOldPasswordMissing.h"
#include "adjunct/quick/sync/view/SyncConstants.h"
#include "adjunct/quick/managers/SyncManager.h"
#include "adjunct/quick_toolkit/widgets/OpIcon.h"
#include "adjunct/quick_toolkit/widgets/OpGroup.h"
#include "adjunct/quick_toolkit/widgets/OpProgressbar.h"
#include "modules/widgets/OpButton.h"
#include "modules/widgets/OpEdit.h"
#include "modules/locale/oplanguagemanager.h"
OP_STATUS SyncOldPasswordMissingDialog::AreYouSureDialog::Init()
{
OpString message;
OpString title;
OpStatus::Ignore(g_languageManager->GetString(Str::D_PASSWORD_MISSING_DOUBLECHECKING_TEXT, message));
OpStatus::Ignore(g_languageManager->GetString(Str::D_PASSWORD_MISSING_DOUBLECHECKING, title));
SetOkTextID(Str::DI_IDYES);
return SimpleDialog::Init(SyncConstant::WINDOW_NAME_AREYOUSURE, title, message, m_parent, TYPE_OK_CANCEL, IMAGE_QUESTION, TRUE);
}
UINT32 SyncOldPasswordMissingDialog::AreYouSureDialog::OnOk()
{
m_parent->m_sync_manager.AbandonPasswordRecovery();
m_parent->CloseDialog(FALSE, FALSE, TRUE);
return 0;
}
SyncOldPasswordMissingDialog::SyncOldPasswordMissingDialog(SyncManager & sync_manager)
: m_sync_manager(sync_manager)
, m_in_progress(FALSE)
{
}
SyncOldPasswordMissingDialog::~SyncOldPasswordMissingDialog()
{
g_main_message_handler->UnsetCallBack(this, MSG_QUICK_PASSWORDS_RECOVERY_KNOWN);
}
void SyncOldPasswordMissingDialog::HandleCallback(OpMessage msg, MH_PARAM_1 par1, MH_PARAM_2 par2)
{
if (msg == MSG_QUICK_PASSWORDS_RECOVERY_KNOWN)
{
if (par2) CloseDialog(FALSE, FALSE, TRUE);
else
{
HideProgressInfo();
ShowError();
}
return;
}
Dialog::HandleCallback(msg, par1, par2);
}
void SyncOldPasswordMissingDialog::OnInit()
{
OpIcon* warning_icon = static_cast<OpIcon*>(GetWidgetByName(SyncConstant::WARNING_ICON));
OP_ASSERT(warning_icon);
if (warning_icon)
{
warning_icon->SetImage("Dialog Warning");
}
OpLabel* title_label = static_cast<OpLabel*>(GetWidgetByName(SyncConstant::HEADER_LABEL));
if (title_label)
{
title_label->SetSystemFontWeight(QuickOpWidgetBase::WEIGHT_BOLD);
title_label->SetRelativeSystemFontSize(SyncConstant::BIGGER);
}
OpEdit* password_edit = static_cast<OpEdit*>(GetWidgetByName(SyncConstant::PASSWORD_EDIT));
if (password_edit) password_edit->SetPasswordMode(TRUE);
OpLabel* password_star = static_cast<OpLabel*>(GetWidgetByName(SyncConstant::PASSWORD_STAR));
if (password_star)
{
password_star->SetJustify(JUSTIFY_RIGHT, FALSE);
password_star->SetForegroundColor(SyncConstant::RED); // todo: put color in skin
}
OpLabel* incorrect = static_cast<OpLabel*>(GetWidgetByName(SyncConstant::INCORR_LABEL));
if (incorrect)
{
incorrect->SetForegroundColor(SyncConstant::RED); // todo: put color in skin
incorrect->SetWrap(TRUE);
}
SetWidgetValue(SyncConstant::RETRY_RADIO, TRUE);
OpProgressBar * progress_spinner = static_cast<OpProgressBar *>(GetWidgetByName(SyncConstant::PROGRESS_SPINNER));
if (progress_spinner)
progress_spinner->SetType(OpProgressBar::Spinner);
OpLabel * progress_label = static_cast<OpLabel *>(GetWidgetByName(SyncConstant::PROGRESS_LABEL));
if (progress_label)
progress_label->SetWrap(TRUE);
HideError();
HideProgressInfo();
//we have no way to react here...
OpStatus::Ignore(g_main_message_handler->SetCallBack(this, MSG_QUICK_PASSWORDS_RECOVERY_KNOWN, 0));
}
void SyncOldPasswordMissingDialog::OnChange(OpWidget *widget, BOOL changed_by_mouse)
{
OpRadioButton* retry_radio = static_cast<OpRadioButton*>(GetWidgetByName(SyncConstant::RETRY_RADIO));
OpRadioButton* replace_radio = static_cast<OpRadioButton*>(GetWidgetByName(SyncConstant::REPLACE_RADIO));
if ((retry_radio && retry_radio == widget) || (replace_radio && replace_radio == widget))
{
BOOL enabled =
retry_radio ?
retry_radio->GetValue() :
replace_radio ? !replace_radio->GetValue() : FALSE;
SetWidgetEnabled(SyncConstant::PASSWORD_LABEL, enabled);
SetWidgetEnabled(SyncConstant::PASSWORD_EDIT, enabled);
SetWidgetEnabled(SyncConstant::PASSWORD_STAR, enabled);
return;
}
Dialog::OnChange(widget, changed_by_mouse);
}
BOOL SyncOldPasswordMissingDialog::OnInputAction(OpInputAction* action)
{
switch (action->GetAction())
{
case OpInputAction::ACTION_OK:
OkClicked();
return TRUE;
case OpInputAction::ACTION_GET_ACTION_STATE:
{
OpInputAction* child_action = action->GetChildAction();
switch (child_action->GetAction())
{
case OpInputAction::ACTION_OK:
{
child_action->SetEnabled(!m_in_progress);
return TRUE;
}
}
break;
}
}
return Dialog::OnInputAction(action);
}
void SyncOldPasswordMissingDialog::OkClicked()
{
if (GetWidgetValue(SyncConstant::RETRY_RADIO)) // Retry recovery
{
ShowProgressInfo(Str::D_FEATURE_SETUP_LOGGING_IN);
OpString old_pass;
GetWidgetText(SyncConstant::PASSWORD_EDIT, old_pass);
m_sync_manager.RetryPasswordRecovery(old_pass); //this will post the message.
}
else // Replace passwords
{
AreYouSureDialog* msg = OP_NEW(AreYouSureDialog, (this));
if (!msg)
return;
if (OpStatus::IsError(msg->Init()))
{
OP_DELETE(msg);
//If anything happend during dialog initialization,
//last thing we are sure of, the user chose to abandon the recovery
m_sync_manager.AbandonPasswordRecovery();
}
}
}
void SyncOldPasswordMissingDialog::ShowError()
{
ShowWidget(SyncConstant::PASSWORD_STAR, TRUE);
ShowWidget(SyncConstant::INCORR_LABEL, TRUE);
CompressGroups();
}
void SyncOldPasswordMissingDialog::HideError()
{
ShowWidget(SyncConstant::PASSWORD_STAR, FALSE);
ShowWidget(SyncConstant::INCORR_LABEL, FALSE);
CompressGroups();
}
void SyncOldPasswordMissingDialog::ShowProgressInfo(Str::LocaleString info_id)
{
SetInProgress(TRUE);
HideError();
ShowWidget(SyncConstant::PROGRESS_SPINNER, TRUE);
OpString info;
OpStatus::Ignore(g_languageManager->GetString(info_id, info));
OpString text;
GetWidgetText(SyncConstant::PROGRESS_LABEL, text);
if (text.Compare(info) != 0)
{
SetWidgetText(SyncConstant::PROGRESS_LABEL, info.CStr());
ResetDialog();
}
}
void SyncOldPasswordMissingDialog::HideProgressInfo()
{
SetInProgress(FALSE);
HideError();
ShowWidget(SyncConstant::PROGRESS_SPINNER, FALSE);
OpString text;
GetWidgetText(SyncConstant::PROGRESS_LABEL, text);
if (text.HasContent())
{
SetWidgetText(SyncConstant::PROGRESS_LABEL, "");
ResetDialog();
}
}
void SyncOldPasswordMissingDialog::SetInProgress(BOOL in_progress)
{
if (m_in_progress != in_progress)
{
m_in_progress = in_progress;
g_input_manager->UpdateAllInputStates();
}
}
|
#include <Wire.h>
#include "Adafruit_Si7021.h"
#include "../RFM95.h"
// Singleton instance of the radio driver
RFM95 radio;
// Create the Si7021 temperature and humid sensor object
Adafruit_Si7021 tempHumidSensor = Adafruit_Si7021();
// Function prototypes
int8_t celciusToFahrenheit(int8_t c);
char data[30];
char buffer[10];
void setup()
{
radio.initRadio();
if (!tempHumidSensor.begin())
Serial.println("Couldn't find Si7021!");
}
void loop()
{
strcpy(data, "TEMPF:");
itoa(celciusToFahrenheit(tempHumidSensor.readTemperature()), buffer, 10);
strcat(data, buffer);
strcat(data, ":HUMID%RH:");
itoa(tempHumidSensor.readHumidity(), buffer, 10);
strcat(data, buffer);
strcat(data, '\0');
Serial.println(data);
radio.sendMessage(data, 30);
delay(5000);
}
/**************************************************************
* Function: celciusToFahrenheit
* ------------------------------------------------------------
* summary: Converts a given temperature in Celcius to its Fahrenheit
* parameters: int8_t Temperature in Celcius
* return: int8_t Temperature in Fahrenheit
**************************************************************/
int8_t celciusToFahrenheit(int8_t c)
{
return (c * 9.0) / 5.0 + 32;
}
|
#include <vector>
#include <string>
#include <iostream>
using namespace std;
class StringVector : vector<void*>{
public:
void push_back(string *s){
vector<void*>::push_back(reinterpret_cast<void*>(s));
}
void push_back(void *s){ vector<void*>::push_back(s); }
string* operator[](size_t idx){
return reinterpret_cast<string*>( vector<void*>::operator[](idx) );
}
};
int main(){
string s1 = "abc";
void *m = malloc(1024);
StringVector sv;
sv.push_back(&s1);
sv.push_back(m);
free(m);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.