本文整理汇总了C++中vec::at方法的典型用法代码示例。如果您正苦于以下问题:C++ vec::at方法的具体用法?C++ vec::at怎么用?C++ vec::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec
的用法示例。
在下文中一共展示了vec::at方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fixWhileLabels
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;
}
}
示例2: plot
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;
}
}
示例3: doubleMatrixDiag
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;
}
示例4: endOfProgram
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());
}
}
示例5: getItemValue
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;
}
示例6: getItemIndex
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
}
示例7: outer_prod
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;
}
示例8: insertColIntoMatrix
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);
}
}