本文整理汇总了C++中Error::buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ Error::buffer方法的具体用法?C++ Error::buffer怎么用?C++ Error::buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::buffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
CommandLine cl;
MathRandom<MathMersenneTwister> rng;
Error error;
ya_check_debug();
YA_MatD input_matrix;
YA_MatD output_matrix;
// Parse the command line
HandleArgs(cl,argc,argv,&error);
string outputfile="";
if (cl.argsize(' ')>0) {
load(cl.argstring(' ',0),input_matrix);
if (cl.argsize(' ')>1)
outputfile=cl.argstring(' ',1);
} else
read(cin,input_matrix);
// Select rows
if (cl['r']) {
output_matrix=input_matrix(YA_RowI(cl.argstring('r',0)),":");
input_matrix=output_matrix;
}
// Select cols
if (cl['c']) {
output_matrix=input_matrix(":",YA_RowI(cl.argstring('c',0)));
input_matrix=output_matrix;
}
// Reorder rows using modulus
else if (cl['z']) {
ya_sizet mod=cl.argint('z',0);
if (mod==0)
error.generate_error(0,"vm_slice","Cannot specify a mod_num of 0.");
if (input_matrix.rows()%mod!=0) {
error.buffer() << "When using -z, the number of rows in the matrix "
<< "must be evenly divisible by the mod_num.";
error.addbuf(0,"vm_slice");
}
YA_VecI row_order(input_matrix.rows());
ya_sizet offset=input_matrix.rows()/mod;
for (ya_sizet i=0; i<input_matrix.rows(); i++) {
div_t index=div(int(i),int(mod));
row_order(i)=index.quot+index.rem*offset;
}
output_matrix=input_matrix(row_order,":");
} else
output_matrix=input_matrix;
ya_sizet file_format=YA_DEFAULT_IO;
if (cl['t'])
file_format=YA_PRETTY_IO;
if (cl['b'])
file_format=YA_BINARY_IO;
// Random subset
if (cl['s']) {
double percent=cl.argdouble('s',0);
if (percent>1)
error.generate_error(0,"mat_convert",
"Random percentage must be between 0 and 1");
YA_RowI rand_perm(randperm(output_matrix.rows(),rng));
output_matrix=copy(output_matrix(rand_perm,":"));
ya_sizet cut_frac=ya_sizet(percent*output_matrix.rows());
if (cl.argstring('s',1)!="NO_OUTPUT")
save(cl.argstring('s',1),
output_matrix(vmcount(cut_frac,":",output_matrix.rows()-1),":"),
file_format);
output_matrix=copy(output_matrix(vmcount(cut_frac),":"));
}
if (cl['q'])
ip_transpose(output_matrix);
if (outputfile=="")
write(cout,output_matrix,file_format);
else
save(outputfile,output_matrix,file_format);
return 0;
}