void fixWhileLabels(){ int label1=labelStack.back(); labelStack.pop_back(); int label2=labelStack.back(); labelStack.pop_back(); labelStack.push_back(label1); labelStack.push_back(label2); if(DEBUG)printf("Zamieniam etykiety %d i %d\n", label1, label2); for(int i=0; i<2; i++){ int jumperLine=jumpStack.back(); if(DEBUG)printf("Skok z %d -> ", jumperLine); str jumper=tempCode.at(jumperLine); if(labelStack.size()==0){ if(DEBUG)printf("NO LABELS LEFT\n"); return; } jumpStack.pop_back(); int labelLine=labelStack.back(); labelStack.pop_back(); char op[10]; char direction[50]; char lab[50]; sscanf(jumper.c_str(), "%s", op); if(DEBUG)printf(" ---> %d\n", labelLine+1); sprintf(lab, "%s %d", op, labelLine+1); str t=lab; tempCode.at(jumperLine)=t; } }
void ArmaPlot::plot(const vec &X, const vec &Y, hold::HOLDSTATE _hold) { assert(X.n_elem == Y.n_elem && "X and Y must have the same shape."); if (this->_hold == hold::off) { scene->clear(); } int scale_x, scale_y; getScales(scale_x, scale_y, X, Y); double X0 = scene->sceneRect().left(); double Y0 = scene->sceneRect().top() - Y.min()*scale_y; for (unsigned int i = 0; i < X.n_elem - 1; ++i) { scene->addLine(X0 + X.at(i)*scale_x, Y0 + Y.at(i)*scale_y, X0 + X.at(i+1)*scale_x, Y0 + Y.at(i+1)*scale_y, *pen); } if (_hold != hold::keep) { this->_hold = _hold; } }
mat doubleMatrixDiag(uint w, const vec& v) { assert(w == v.n_rows); mat res = zeros(w,w); for(uint i = 0; i < w; i++) { res.at(i*w + i) = v.at(i); } return res; }
void endOfProgram(){ if(DEBUG)printf("Koniec programu, zwracam HALT\nKOD:\n"); addCodeLine("HALT"); for(int i=0; i<tempCode.size(); i++){ if(DEBUG || LINECODE)printf("%d. ", i); printf("%s\n", tempCode.at(i).c_str()); } }
str getItemValue(int index){ if(DEBUG)printf("A"); if(index>constantVector.size()){ if(ERR)printf("POZA ZAKRESEM\n"); return NULL; } return constantVector.at(index)->value; }
str getItemValue(str constName){ int i=getItemIndex(constName); if(i==-1){ //if(ERR)printf("*******Nie znaleziono wartosci stalej %s\n", constName.c_str()); return NULL; } return constantVector.at(i)->value; }
int getItemIndex(str constName){ for(int i=0; i<constantVector.size(); i++){ if(constName==constantVector.at(i)->name){ return i; //found } } //if(ERR)printf("*******Nie znaleziono stalej %s\n", constName.c_str()); return -1; //not found }
int getItemIndex(str varName){ for(int i=0; i<variableVector.size(); i++){ if(varName==variableVector.at(i)){ return i+reserved_registers_number; } } //if(ERR)printf("*******nie ma takiej zmiennej"); return -1; }
mat outer_prod(const rowvec& v1, const vec& v2) { assert(v1.n_cols == v2.n_rows); uint size = v1.n_cols; mat res(size, size); for(uint c = 0 ; c < size; c++) { for(uint r = 0; r < size; r++) { res.at(r,c) = v1.at(c) * v2.at(r); } } return res; }
void insertColIntoMatrix(int c, const vec& v, mat& m) { assert(v.n_rows == m.n_rows); for(uint r = 0; r < v.n_rows; r++) { m.at(r,c) = v.at(r); } }