本文整理汇总了C++中readMatrix函数的典型用法代码示例。如果您正苦于以下问题:C++ readMatrix函数的具体用法?C++ readMatrix怎么用?C++ readMatrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readMatrix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void init(int argc, char** argv){
if (argc != 2 || atoi(argv[1]) <= 0)
exit(1);
numUnixProcess = atoi(argv[1]);
//Read Files
readMatrix("ini1.txt", &mAlines, &mAcolumns, &matrixA);
readMatrix("ini2.txt", &mBlines, &mBcolumns, &matrixB);
//check
if (mAcolumns != mBlines){
printf("Can't multiply.\n\n");
exit(1);
}
mResultlines = mAlines;
mResultcolumns = mBcolumns;
matrixResult = (int*) mmap(0, mResultlines * mResultcolumns * sizeof(int), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON,-1,0);
if (numUnixProcess > mResultlines){
numUnixProcess = mResultlines;
}
}
示例2: readMatrix
void ManipTool::load_parameters(std::string fn_nv, std::string fn_rorate,std::string fn_trans,std::string fixed_rel){
if((is_file_exist(fn_nv.c_str()) == true)&&(is_file_exist(fn_rorate.c_str()) == true)&&\
(is_file_exist(fn_trans.c_str()) == true)&&(is_file_exist(fixed_rel.c_str()) == true)){
f_nv.open(fn_nv.c_str());
ts.rel_o = readMatrix(f_nv);
f_nv.close();
f_fixed_rel_o.open(fixed_rel.c_str());
ts.m_fixed_rel_o= readMatrix(f_fixed_rel_o);
f_fixed_rel_o.close();
f_rotate.open(fn_rorate.c_str());
ts.rotate_s2sdot = readMatrix(f_rotate);
f_rotate.close();
f_trans.open(fn_trans.c_str());
est_trans = readMatrix(f_trans);
std::cout<<"init position "<<est_trans<<std::endl;
std::cout<<"rel_o "<<ts.rel_o<<std::endl;
std::cout<<"rotation are "<<ts.rotate_s2sdot<<std::endl;
f_trans.close();
// est_trans(0) += 0.5*(double) rand() / (RAND_MAX);
// est_trans(1) += 0.5*(double) rand() / (RAND_MAX);
// est_trans(2) += 0.5*(double) rand() / (RAND_MAX);
}
else{
std::cout<<"tool parameters files are not exist"<<std::endl;
exit(0);
}
}
示例3: main
void main()
{
int A[MAXROWS][MAXCOLS], B[MAXROWS][MAXCOLS],
C[MAXROWS][MAXCOLS];
int M, N;
/*Function declarations*/
void readMatrix(int arr[][MAXCOLS], int M, int N);
void printMatrix(int arr[][MAXCOLS], int M, int N);
void productMatrix(int A[][MAXCOLS], int B[][MAXCOLS], int C[][MAXCOLS],
int M, int N);
// clrscr();
printf("Enter the value of M and N\n");
scanf("%d %d",&M, &N);
printf ("Enter matrix A\n");
readMatrix(A,M,N);
printf("Matrix A\n");
printMatrix(A,M,N);
printf ("Enter matrix B\n");
readMatrix(B,M,N);
printf("Matrix B\n");
printMatrix(B,M,N);
productMatrix(A,B,C, M,N);
printf ("The product matrix is\n");
printMatrix(C,M,N);
}
示例4: main
int main(int argc, char *argv[])
{
if(argc < 2) {
printf("Usage: matrix-thread nThreads\n");
return -1;
}
numThreads = atoi(argv[1]);
A = readMatrix(IN_1);
B = readMatrix(IN_2);
if(A->numCols != B->numRows) {
fprintf(stderr, "Wrong matrix dimensions\n");
return -1;
}
C = makeMatrix(A->numRows, B->numCols);
dispatchThreads();
writeMatrix(OUTPUT_FILE, C);
freeMatrix(A);
freeMatrix(B);
freeMatrix(C);
return 0;
}
示例5: p3b
void p3b(void)
{
int ** matrix1=readMatrix("matrix1.txt");
int ** matrix2=readMatrix("matrix2.txt");
int ** subMatrix = sub(matrix1, matrix2, 1, 1, 0, 1, 3);
printMatrix(MATSIZE,matrix1);
printMatrix(MATSIZE,matrix2);
printMatrix(3,subMatrix);
}
示例6: p2
void p2(void)
{
int matrix1[MATSIZE][MATSIZE];
int matrix2[MATSIZE][MATSIZE];
int sumMatrix[MATSIZE][MATSIZE];
readMatrix("matrix1.txt", (int *)matrix1);
readMatrix("matrix2.txt", (int *)matrix2);
sum((int *)matrix1, (int *)matrix2,(int *)sumMatrix,MATSIZE);
printMatrix(MATSIZE,(int *)matrix1);
printMatrix(MATSIZE,(int *)matrix2);
printMatrix(MATSIZE,(int *)sumMatrix);
}
示例7: initPrior
/* Public initialisations functions */
st_parts_at * initPrior(char* dir)
{
dir = addInputPath(dir);
st_parts_at *prior_parts;
char *residual_file= createPath(dir, "residuals.csv");
char *species_prior_file= createPath(dir, "species_prior.csv");
prior_parts = (st_parts_at *) malloc(sizeof(st_part_at));
prior_parts->sps = readMatrix(species_prior_file);
prior_parts->res = readMatrix(residual_file);
return(prior_parts);
}
示例8: main
int main(int argc, char const *argv[])
{
Matrix *m1 = readMatrix(getFileMatrixName(argc, argv, 1));
Matrix *m2 = readMatrix(getFileMatrixName(argc, argv, 2));
int process = getNumberOfProcessOrThreadNumber(argc, argv);
Matrix result = multipleMatrixUsingProcess(*m1,*m2, process);
writeMatrix("out.txt", result);
return 0;
}
示例9: input
void LDAModel::readFromFile(string filename)
{
ifstream input(filename.c_str());
if (!input)
{
throw BALL::Exception::FileNotFound(__FILE__, __LINE__, filename);
}
String line0;
getline(input, line0); // skip comment line
getline(input, line0); // read read line containing model specification
if (line0.getField(0, "\t") != type_)
{
String e = "Wrong input data! Use training data file generated by a ";
e = e + type_ + " model !";
throw Exception::WrongDataType(__FILE__, __LINE__, e.c_str());
}
int no_descriptors = line0.getField(2, "\t").toInt();
int no_y = line0.getField(3, "\t").toInt();
bool centered_data = line0.getField(4, "\t").toInt();
int no_classes = line0.getField(5, "\t").toInt();
bool trained = line0.getField(6, "\t").toBool();
substance_names_.clear();
getline(input, line0); // skip empty line
readModelParametersFromFile(input);
Model::readDescriptorInformationFromFile(input, no_descriptors, centered_data);
if (!trained)
{
sigma_.resize(0, 0);
return;
}
readClassInformationFromFile(input, no_classes);
readMatrix(sigma_, input, no_descriptors, no_descriptors);
getline(input, line0); // skip empty line
mean_vectors_.resize(no_y);
for (int c = 0; c < no_y; c++) // read all mean-vector matrices
{
readMatrix(mean_vectors_[c], input, no_classes, no_descriptors);
}
input.close();
}
示例10: readMatrixCart
double* readMatrixCart(char *nomFichier, int matrix_size, int nbCols, int nbLines,
int coords[])
{
char *line = malloc(256);
size_t len;
ssize_t end;
char *endNb;
FILE *file;
int i = 0;
int j;
char *ptr;
double *matrice = readMatrix(nomFichier, matrix_size, matrix_size);
double *bloc = (double*)malloc(nbLines*nbCols*sizeof(double));
//On prend la partie qu'on a besoin
for(i = 0; i < nbLines; i++) {
for(j = 0; j < nbCols; j++) {
int pos = (coords[0]*nbLines+i)*matrix_size+(coords[1]*nbCols) + j;
bloc[i*nbCols + j] = matrice[pos];
}
}
free(matrice);
return bloc;
}
示例11: fileInfo
void SphereGenerator::genObj()
{
isCircle = 0;
QFileInfo fileInfo(fileName);
if(!fileInfo.exists())
{
std::cout << "error: file does not exist" << std::endl;
return;
}
QDir baseDir(fileInfo.absoluteDir());
QSettings settings(fileInfo.absoluteFilePath(),QSettings::IniFormat);
// read in width
sX = settings.value("sample/numX").toInt();
sZ = settings.value("sample/numZ").toInt();
sMatrixFile = QDir::cleanPath(QDir(baseDir).filePath(settings.value("sample/matrixfile").toString()));
sTexture = QDir::cleanPath(QDir(baseDir).filePath(settings.value("sample/texture").toString()));
sObj = QDir::cleanPath(QDir(baseDir).filePath(settings.value("sample/outputobj").toString()));
isCircle = settings.value("circle/circle").toInt();
// initialize
projList.clear();
mvList.clear();
centerList.clear();
readMatrix(sMatrixFile);
deComposeMV();
output();
}
示例12: p4
void p4(void)
{
int matrix1[MATSIZE][MATSIZE];
readMatrix("matrix1.txt", (int *)matrix1);
printMatrix(MATSIZE,(int *)matrix1);
printf("The determinant of the matrix is %d\n",determinant(MATSIZE,(int *)matrix1));
}
示例13: addInputPath
/* MCMC Var-Cov tuning matrix */
st_mcmc_update *initMCMCUpdate(char *dir)
{
st_mcmc_update *mcmc_update;
dir = addInputPath(dir);
char *tuning_file = createPath(dir, "tuning.csv");
gsl_matrix *tuning = readMatrix(tuning_file);
char *fixed_file = createPath(dir, "fixed.csv");
gsl_vector *fixed = readVector(fixed_file);
if(tuning->size1 != tuning->size2 || tuning->size1 != fixed->size) {
printf("Error in initMCMCUpdate\n");
exit(GSL_FAILURE);
}
gsl_vector *z = gsl_vector_alloc(fixed->size);
mcmc_update = (st_mcmc_update *) malloc(sizeof(st_mcmc_update));
mcmc_update->tuning = tuning;
mcmc_update->fixed=fixed;
mcmc_update->z = z;
mcmc_update->always_accept = 1;
int i;
for(i=0; i<fixed->size; i++)
mcmc_update->always_accept *= (int) VGET(mcmc_update->fixed, i);
return(mcmc_update);
}
示例14: sprintf
void MatrixMarket2Bin::convert(const char *filename) {
char bin_file[512];
sprintf(bin_file, "%s.bin", filename);
readMatrix(filename);
writeMatrix(bin_file);
}
示例15: SM_ASSERT_EQ
MatrixArchive::BlockType MatrixArchive::readBlock(std::istream & fin, std::string & name, Eigen::MatrixXd & matrix, std::string & stringValue) const
{
char start, end;
// start character
fin.read(&start,1);
BlockType blockType;
if(start == s_magicCharStartAStringBlock){
blockType = STRING;
}
else{
SM_ASSERT_EQ(MatrixArchiveException, start, s_magicCharStartAMatrixBlock, "The block didn't start with the expected character");
blockType = MATRIX;
}
// 64 character name
char nameBuffer[s_fixedNameSize + 1];
nameBuffer[s_fixedNameSize] = '\0';
fin.read(nameBuffer,(std::streamsize)s_fixedNameSize);
name = nameBuffer;
boost::trim(name);
switch(blockType){
case MATRIX:
readMatrix(fin, matrix);
break;
case STRING:
readString(fin, stringValue);
break;
}
// end character
fin.read(&end,1);
SM_ASSERT_EQ(MatrixArchiveException, end, s_magicCharEnd, "The matrix block didn't end with the expected character");
return blockType;
}