• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ readMatrix函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中readMatrix函数的典型用法代码示例。如果您正苦于以下问题:C++ readMatrix函数的具体用法?C++ readMatrix怎么用?C++ readMatrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了readMatrix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
  }
}
开发者ID:raffaelnagel,项目名称:Sisop-II,代码行数:26,代码来源:PUnixMatrixMultiplication.c


示例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);
    }

}
开发者ID:liqiang1980,项目名称:VTFS,代码行数:28,代码来源:maniptool.cpp


示例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);
}
开发者ID:DouglasAllen,项目名称:A-few-C-programs,代码行数:32,代码来源:ProductOf2Matrices.c


示例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;
}
开发者ID:mhbackes,项目名称:sisop2,代码行数:25,代码来源:matrix-thread.c


示例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);
}
开发者ID:gabrielarpino,项目名称:C-Labs,代码行数:9,代码来源:main.c


示例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);
}
开发者ID:bBusker,项目名称:CSC190,代码行数:12,代码来源:main.c


示例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);
}    
开发者ID:csgillespie,项目名称:hybrid-pmcmc,代码行数:14,代码来源:init.c


示例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;
}
开发者ID:FelipeLahti,项目名称:ufrgs-sisop2-threads-process,代码行数:13,代码来源:app_unix_process.c


示例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();
		}
开发者ID:HeyJJ,项目名称:ball,代码行数:49,代码来源:ldaModel.C


示例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;

}
开发者ID:glahaie,项目名称:Parallel-LU-Factorization,代码行数:29,代码来源:lu_mpi_cart.c


示例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();
}
开发者ID:h005,项目名称:3DfeatureCheck,代码行数:29,代码来源:spheregenerator.cpp


示例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));
}
开发者ID:bBusker,项目名称:CSC190,代码行数:7,代码来源:main.c


示例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);
}
开发者ID:csgillespie,项目名称:hybrid-pmcmc,代码行数:30,代码来源:init.c


示例14: sprintf

void MatrixMarket2Bin::convert(const char *filename) {
  char bin_file[512];
  sprintf(bin_file, "%s.bin", filename);

  readMatrix(filename);
  writeMatrix(bin_file);
}
开发者ID:falcong,项目名称:parkway,代码行数:7,代码来源:MatrixMarket2Bin.cpp


示例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;
  }
开发者ID:mbuerki,项目名称:Schweizer-Messer,代码行数:35,代码来源:MatrixArchive.cpp


示例16: readMatrixFromFile

Eigen::MatrixXd readMatrixFromFile(const std::string &filename, int_t rows, int_t cols)
{
    Eigen::MatrixXd M = readMatrix(filename);
    REQUIRE(M.rows() == rows);
    REQUIRE(M.cols() == cols);
    return M;
}
开发者ID:acados,项目名称:acados,代码行数:7,代码来源:read_matrix.cpp


示例17: readMatrix

Class_Substitution_Matrix::Class_Substitution_Matrix(string * filename){

	aminoacid_alphabetSize=20; // 0-19
	gapChar = aminoacid_alphabetSize;
	aminoacid_ascii2num = new int [256];

	aminoacid_num2ascii = new char[aminoacid_alphabetSize+1];
	for (int i=0; i<= aminoacid_alphabetSize; i++) {aminoacid_num2ascii[i] = '-';}  // all upper case

	// hmm: ACDEFGHIKLMNPQRSTVWY
	for (int i=0; i< 256; i++) {aminoacid_ascii2num[i] = gapChar;}	  // initialize with invalid/gap character
	// no amino acids: O,U,B,J,X,Z - treat as gap...
	int j=0;
	for (int i='A'; i<= 'Z'; i++) {
		if (i=='B' || i=='J' || i=='O' || i=='U' || i=='X' || i=='Z') {
			aminoacid_ascii2num[i] = gapChar;
		} else {
			aminoacid_ascii2num[i] = j;
			aminoacid_num2ascii[j] = i;

			j++;
		}
	}



	this->matrix = readMatrix(filename);

}
开发者ID:wgerlach,项目名称:CARMA3,代码行数:29,代码来源:matrix.cpp


示例18: readMatrixCyclic

double* readMatrixCyclic(char *nomFichier, int matrix_size, int nbLines, int rank, 
        int nodes) 
{

    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*matrix_size*sizeof(double));

    //On prend la partie qu'on a besoin
    for(i = 0; i < nbLines; i++) {
        for(j = 0; j < matrix_size; j++) {
            bloc[i*matrix_size + j] = matrice[(i*nodes+rank)*matrix_size + j];
        }
    }

    if(matrice) free(matrice);
    return bloc;

}
开发者ID:glahaie,项目名称:Parallel-LU-Factorization,代码行数:28,代码来源:lu_mpi_row_cyclic.c


示例19: checkDeadlock

int checkDeadlock(int n)
{
	struct sembuf sb;
    sb.sem_flg = SEM_UNDO;
    sb.sem_num = MATRIX;
    sb.sem_op = -1;
    if(semop(sid, &sb, 1) == -1)
    {
        perror("semop");
        exit(1);
    }
    readMatrix(n);
    sb.sem_op = 1;
    if(semop(sid, &sb, 1) == -1)
    {
        perror("semop");
        exit(1);
    }
    int i, j, f[4];
    for(i=0;i<4;i++)
    	f[i] = 0;
    for(i=0;i<n;i++)
    {
    	for(j=0;j<4;j++)
    	{
    		if(A[i][j]==2 && A[i][(j+1)%4]==1)
    			f[j] = 1;
    	}
    }
    if(f[0]==1 && f[1]==1 && f[2]==1 && f[3]==1)
    	return 1;
    else
    	return 0;
}
开发者ID:kalyan-kumar,项目名称:os-lab,代码行数:34,代码来源:Manager.c


示例20: main

int main() {
    Matrix *mat = readMatrix("input.txt");
    if(gaussJordan(mat) == 1) printf("error\n");;
    //printMat(mat,mat -> size);
    writeMatrix(mat);
    destroyMat(mat);
    return 0;
}
开发者ID:mduffin95,项目名称:inversion,代码行数:8,代码来源:inverter.c



注:本文中的readMatrix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ readMessage函数代码示例发布时间:2022-05-30
下一篇:
C++ readLongLong函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap