本文整理汇总了C++中read_matrix函数的典型用法代码示例。如果您正苦于以下问题:C++ read_matrix函数的具体用法?C++ read_matrix怎么用?C++ read_matrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_matrix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(void) {
FILE *fin = fopen( "matrix2.in", "r" );
if( fin == NULL ) {
printf( "Error: could not open matrix2.in\n" );
exit( EXIT_FAILURE );
}
Matrix *a = read_matrix( fin );
Matrix *b = read_matrix( fin );
fclose( fin );
Matrix *c = product_matrix( a, b );
FILE *output = fopen( "matrix2.out", "w" );
if( output == NULL ) {
printf( "Error: could not open matrix2.out\n" );
exit( EXIT_FAILURE );
}
print_matrix( output, c );
fclose( output );
destroy_matrix( a );
destroy_matrix( b );
destroy_matrix( c );
return 0;
}
开发者ID:bengolder,项目名称:s096,代码行数:30,代码来源:template_matrix2.c
示例2: main
void main()
{
int row1, column1, row2, column2;
int matrix1[100][100], matrix2[100][100], final_matrix[100][100];
printf("Enter number of rows and columns of matrix 1\n");
scanf_s("%d%d", &row1, &column1);
printf("Enter elements of matrix 1\n");
read_matrix(row1, column1, matrix1);
printf("Enter number of rows and columns of matrix 2\n");
scanf_s("%d%d", &row2, &column2);
if (column1 != row2)
printf("Matrices cannot be multiplied \n");
else
{
printf("Enter elements of matrix 2\n");
read_matrix(row2, column2, matrix2);
}
printf("Matrix 1 is as follows \n");
display_matrix(row1, column1, matrix1);
printf("Mtrix 2 is as follows \n");
display_matrix(row2, column2, matrix2);
multiply_matrix(row1, column1, matrix1, row2, column2, matrix2, final_matrix);
printf("Resultant Matrix is as follows \n");
display_matrix(row1, column2, final_matrix);
getchar();
getchar();
getchar();
}
开发者ID:meshubh,项目名称:extra_problems,代码行数:28,代码来源:mult_matrix.c.c
示例3: printf
void *read_all()
{
printf("---!!! READ ALL THREAD START !!!---\n");
read_matrix(matrixa);
read_matrix(matrixb);
printf("---!!! READ ALL THREAD END !!!---\n");
sem_post(&mutex);
return 0;
}
开发者ID:plotnikovanton,项目名称:ITMO,代码行数:9,代码来源:part2.c
示例4: load_data
// Read binary ROM data for basis functions and coefficients
static int load_data(const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre) {
// Load binary data for amplitude and phase spline coefficients as computed in Mathematica
int ret = XLAL_SUCCESS;
ret |= read_vector(dir, "SEOBNRv1ROM_SS_Amp_ciall.dat", cvec_amp);
ret |= read_vector(dir, "SEOBNRv1ROM_SS_Phase_ciall.dat", cvec_phi);
ret |= read_matrix(dir, "SEOBNRv1ROM_SS_Bamp_bin.dat", Bamp);
ret |= read_matrix(dir, "SEOBNRv1ROM_SS_Bphase_bin.dat", Bphi);
ret |= read_vector(dir, "SEOBNRv1ROM_SS_AmpPrefac_ci.dat", cvec_amp_pre);
return(ret);
}
开发者ID:astrophysicsvivien,项目名称:lalsuite,代码行数:11,代码来源:LALSimIMRSEOBNRv1ROMEffectiveSpin.c
示例5: main
int main()
{
int N;
scanf("%d",&N);
int *matrix_a = (int *)malloc(N * N * sizeof(int));
int *matrix_b = (int *)malloc(N * N * sizeof(int));
int *matrix_c = (int *)malloc(N * N * sizeof(int));
read_matrix(matrix_a, N);
read_matrix(matrix_b, N);
multiply_matrix_3(matrix_a, matrix_b, matrix_c, N);
display_matrix(matrix_c, N);
}
开发者ID:sarumaha,项目名称:cachediff,代码行数:12,代码来源:multiply3.c
示例6: fclib_read_local
/** read local problem;
* return problem on success; NULL on failure */
struct fclib_local* fclib_read_local (const char *path)
{
struct fclib_local *problem;
hid_t file_id, main_id, id;
if ((file_id = H5Fopen (path, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
{
fprintf (stderr, "ERROR: opening file failed\n");
return NULL;
}
if (!H5Lexists (file_id, "/fclib_local", H5P_DEFAULT))
{
fprintf (stderr, "ERROR: spurious input file %s :: fclib_local group does not exists", path);
return NULL;
}
MM (problem = calloc (1, sizeof (struct fclib_local)));
IO (main_id = H5Gopen (file_id, "/fclib_local", H5P_DEFAULT));
IO (H5LTread_dataset_int (file_id, "/fclib_local/spacedim", &problem->spacedim));
IO (id = H5Gopen (file_id, "/fclib_local/W", H5P_DEFAULT));
problem->W = read_matrix (id);
IO (H5Gclose (id));
if (H5Lexists (file_id, "/fclib_local/V", H5P_DEFAULT))
{
IO (id = H5Gopen (file_id, "/fclib_local/V", H5P_DEFAULT));
problem->V = read_matrix (id);
IO (H5Gclose (id));
IO (id = H5Gopen (file_id, "/fclib_local/R", H5P_DEFAULT));
problem->R = read_matrix (id);
IO (H5Gclose (id));
}
IO (id = H5Gopen (file_id, "/fclib_local/vectors", H5P_DEFAULT));
read_local_vectors (id, problem);
IO (H5Gclose (id));
if (H5Lexists (file_id, "/fclib_local/info", H5P_DEFAULT))
{
IO (id = H5Gopen (file_id, "/fclib_local/info", H5P_DEFAULT));
problem->info = read_problem_info (id);
IO (H5Gclose (id));
}
IO (H5Gclose (main_id));
IO (H5Fclose (file_id));
return problem;
}
开发者ID:xhub,项目名称:fclib,代码行数:55,代码来源:fclib.c
示例7: main
int main(void) {
matrix a,b,c;
printf("enter first matrix\n");
read_matrix(&a);
print_matrix(&a);
printf("enter second matrix\n");
read_matrix(&b);
print_matrix(&b);
printf("matrix product\n");
multiply(&a, &b, &c);
print_matrix(&c);
return 0;
}
开发者ID:armenr,项目名称:algorist,代码行数:13,代码来源:matrix-demo.c
示例8: main
int main(int argc, char ** argv){
matrix * matrix_a;
matrix * matrix_b;
int thread_count = 0;
// if(argc != 7){
// fprintf(stderr, "%s", "Not enough arguments");
// exit(-1);
// }
for(int i = 1; i < argc; i ++){
if(strcmp(argv[i],"-a") == 0){
matrix_a = read_matrix(argv[i+1]);
}
if(strcmp(argv[i],"-b") == 0){
matrix_b = read_matrix(argv[i+1]);
}
if(strcmp(argv[i],"-t") == 0){
thread_count = atoi(argv[i+1]);
}
}
if(matrix_a->cols != matrix_b->rows){
fprintf(stderr, "%s", "a and b not computable");
exit(-1);
}
printf("Read ready, start computing");
pthread_t thread_id;
int err;
in_arg * arg = (in_arg *)malloc(sizeof(in_arg));
out_arg * result = (out_arg *)malloc(sizeof(out_arg));
arg->a = matrix_a;
arg->b = matrix_b;
arg->from_row = 0;
arg->to_row = matrix_a->rows - 1;
err = pthread_create(&thread_id, NULL, compute_thread, (void*)arg);
err = pthread_join(thread_id, (void**)result);
// double * result_matrix = (double *)malloc(matrix_a->rows * matrix_b->cols * sizeof(double));
// for(int i = 0 ; i < matrix_a->rows; i++){
// double *one_strip = compute_strip(matrix_a,matrix_b,i);
// for(int j = 0 ; j < matrix_a->cols; j++){
// result_matrix[i * matrix_b->cols + j] = one_strip[j];
// }
// free(one_strip);
// }
for(int i = 0 ; i < matrix_a->rows * matrix_b->cols; i ++){
printf("%f ",result->result[i]);
if(i % matrix_b->cols == matrix_b->cols-1)
printf("\n");
}
}
开发者ID:wangyuesong,项目名称:CS170OS,代码行数:51,代码来源:one_thread.c
示例9: Call_Inverse
void Call_Inverse( int n)
{
POLY ds;
POLY M1[n][n], t_M1[n][n], product[n][n];
int k;
printf("Please choose the test matrix: ");
printf("1 random matrix.\n");
printf("2 input your own matrix.\n");
scanf("%d", &k ); printf("%d\n", k);
if(k==1) random_matrix ( n, n, M1);
if(k==2) read_matrix( n, n, M1 );
printf("the original matrix generated :\n");
print( n, n, M1);
copy(n, n, M1, t_M1);
ds = Inverse_Poly ( n, M1 );
printf(" The inverse matrix of the matrix is :\n" );
print(n, n, M1 );
printf(" The polynomial ds is :\n" );
Print_Poly( ds.d, ds.p );
printf("The product (without ds) of the original matrix");
printf(" and the inverse matrix is:\n");
Multiply(n, n, n, M1, t_M1, product);
print(n, n, product);
free_matrix(n, n, M1);
free_matrix(n, n, t_M1);
free_matrix(n, n, product);
}
开发者ID:Iamthewood,项目名称:PHCpack,代码行数:34,代码来源:ts_poly_inverse.c
示例10: main
main ()
{
int n;
MATRIX (A, MAX*MAX, MAX, MAX)
read_matrix (A);
if (DIM(A,0) != DIM(A,1))
{
printf ("La matrice doit etre carree\n");
return;
}
n = DIM(A,0);
MATRIX (B, MAX*MAX, n, n)
printf ("Inversion de la matrice : ");
print_matrix (A);
pivot (A, B);
printf ("Matrice inverse : ");
print_matrix (B);
ENDMAT ENDMAT
}
开发者ID:jbailhache,项目名称:log,代码行数:26,代码来源:PIVOT.C
示例11: stripBlankEnds
bool SimGPS::OnStartUp()
{
list<string> sParams;
m_MissionReader.EnableVerbatimQuoting(false);
if(m_MissionReader.GetConfiguration(GetAppName(), sParams)) {
list<string>::iterator p;
for(p=sParams.begin(); p!=sParams.end(); p++) {
string original_line = *p;
string param = stripBlankEnds(toupper(biteString(*p, '=')));
string value = stripBlankEnds(*p);
if(param == "GPS_COVARIANCE") {
GPS_covariance = read_matrix(value);
}
if(param == "MAX_DEPTH"){
max_depth = atof(value.c_str());
}
if(param == "ADD_NOISE"){
add_noise = (tolower(value) == "true");
}
if(param == "BACKGROUND_MODE"){
if (tolower(value) == "true")
in_prefix = "NAV";
else
in_prefix = "SIM";
}
}
}
distribution = normal_distribution<double>(0.0,sqrt(GPS_covariance(0,0)));
RegisterVariables();
return(true);
}
开发者ID:liampaull,项目名称:AUVCSLAM,代码行数:34,代码来源:SimGPS.cpp
示例12: main
int main(int argc, char *argv[])
{
double* matA = _mm_malloc(WIDTH*HEIGHT*sizeof(double), 64);
double* matB = _mm_malloc((WIDTH*HEIGHT)*sizeof(double), 64);
double* prod = _mm_malloc(WIDTH*HEIGHT*sizeof(double), 64);
double* prod_ref = _mm_malloc(WIDTH*HEIGHT*sizeof(double), 64);
int read_flag = read_matrix(TEST_FILENAME, prod_ref, matA, matB);
if (read_flag == 1)
printf("Cannot open test file\n");
else if (read_flag == 2)
printf("Error while reading data from test file");
else if (read_flag == 3)
printf("Error while closing the test file");
if (read_flag)
return 0;
uint64_t start = timestamp_us();
matmul_optimize(prod, matA, matB); /* run the optimization functions. */
uint64_t time = timestamp_us() - start;
if (compare_matrix(prod, prod_ref)) {
printf("%lu incorrect\n", time);
} else {
printf("%lu\n", time);
}
_mm_free(prod_ref);
_mm_free(prod);
_mm_free(matB);
_mm_free(matA);
return 0;
}
开发者ID:Hurricane-Jason-Harry,项目名称:MatrixOptimization,代码行数:32,代码来源:main.c
示例13: main
int main () {
// read two N x N matrices
read_matrix (X);
read_matrix (Y);
// multiply the matrices
matrix_multiply (X, Y, Z);
// output the resulting matrix
print_matrix (Z);
return 0;
}
开发者ID:pranamibhatt,项目名称:Computer_Architecture,代码行数:16,代码来源:reg-mm.c
示例14: zbuildshadingpattern
/* <pattern> <matrix> <shading> .buildshadingpattern <pattern> <instance> */
static int
zbuildshadingpattern(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
os_ptr op2 = op - 2;
gs_matrix mat;
gs_pattern2_template_t templat;
int_pattern *pdata;
gs_client_color cc_instance;
int code;
check_type(*op2, t_dictionary);
check_dict_read(*op2);
gs_pattern2_init(&templat);
if ((code = read_matrix(imemory, op - 1, &mat)) < 0 ||
(code = dict_uid_param(op2, &templat.uid, 1, imemory, i_ctx_p)) != 1 ||
(code = shading_param(op, &templat.Shading)) < 0 ||
(code = int_pattern_alloc(&pdata, op2, imemory)) < 0
)
return_error((code < 0 ? code : gs_error_rangecheck));
templat.client_data = pdata;
code = gs_make_pattern(&cc_instance,
(const gs_pattern_template_t *)&templat,
&mat, igs, imemory);
if (code < 0) {
ifree_object(pdata, "int_pattern");
return code;
}
make_istruct(op - 1, a_readonly, cc_instance.pattern);
pop(1);
return code;
}
开发者ID:computersforpeace,项目名称:ghostpdl,代码行数:33,代码来源:zshade.c
示例15: get_proxy
int get_proxy(char * proxypath,char sep){
/* int i=8; */
/* fprintf(stderr,"in mcmc AS[%d]=%d\n",i,23); */
int ff;
char fff[20];
int midx = 0;
fprintf(stderr,"MODE in sir %d\n",MODE);
ADJL = (double ***)calloc((lastPROXY-firstPROXY+1), sizeof(double**));
for (ff = firstPROXY; ff <= lastPROXY; ff++){
/* fprintf(stderr,"proxy numero %d\n",ff); */
char * file = (char *)calloc(1000,sizeof(char));
file = strcat(file,proxypath);
/* fprintf(stderr,"proxy file %s\n",file); */
if((MODE == 2)||(MODE==3))
file = strcat(file,"/Adj_");
if((MODE == 0)||(MODE==1))
file = strcat(file,"/Adj_");
sprintf(fff,"%d",ff);
//if((MODE == 2)||(MODE==3)){
//sprintf(fff,"%d",0); //// PRENDOLASOMMATOTALE!!! 0
// sprintf(fff,"%s","0binary"); //// PRENDOLASOMMATOTALE BINARIZZATA!!! 0binary
//}
file = strcat(file,fff);
/* fprintf(stderr,"proxy file %s\n",file); */
ADJL[midx] = (double **) calloc ((N+1), sizeof(double*));
read_matrix(ADJL[midx], file, midx, sep);
midx++;
/* fprintf(stderr,"proxy dopo numero %d\n",midx); */
free(file);
}
return 0;
}
开发者ID:visintainer,项目名称:Epi,代码行数:32,代码来源:get_param.c
示例16: main
int
main (void)
{
matrix_t r = read_matrix ();
matrix_t mayw;
matrix_t mustw;
dm_copy(&r, &mayw);
dm_copy(&r, &mustw);
printf ("matrix:\n");
dm_print (stdout, &r);
// nub
dm_sort_rows (&r, &mayw, &mustw, &max_row_first);
dm_nub_rows (&r, &mayw, &mustw, &eq_rows, NULL);
// optimize
dm_optimize (&r, &mayw, &mustw);
// sort again
dm_sort_rows (&r, &mayw, &mustw, &max_row_first);
printf ("matrix:\n");
dm_print (stdout, &r);
printf ("state mapping:\n");
state_mapping (&r);
printf ("transition mapping:\n");
transition_mapping (&r);
printf ("dependencies:\n");
dependencies (&r);
return 0;
}
开发者ID:graydon,项目名称:ltsmin,代码行数:29,代码来源:test-regroup.c
示例17: zrectstroke
/* <numarray|numstring> rectstroke - */
static int
zrectstroke(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gs_matrix mat;
local_rects_t lr;
int npop, code;
if (read_matrix(imemory, op, &mat) >= 0) {
/* Concatenate the matrix to the CTM just before stroking the path. */
npop = rect_get(&lr, op - 1, imemory);
if (npop < 0)
return npop;
code = gs_rectstroke(igs, lr.pr, lr.count, &mat);
npop++;
} else {
/* No matrix. */
npop = rect_get(&lr, op, imemory);
if (npop < 0)
return npop;
code = gs_rectstroke(igs, lr.pr, lr.count, (gs_matrix *) 0);
}
rect_release(&lr, imemory);
if (code < 0)
return code;
pop(npop);
return 0;
}
开发者ID:ststeiger,项目名称:ghostsvg,代码行数:29,代码来源:zdps1.c
示例18: fclib_read_global
/** read global problem;
* return problem on success; NULL on failure */
struct fclib_global* fclib_read_global (const char *path)
{
struct fclib_global *problem;
hid_t file_id, main_id, id;
if ((file_id = H5Fopen (path, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
{
fprintf (stderr, "ERROR: opening file failed\n");
return NULL;
}
MM (problem = calloc (1, sizeof (struct fclib_global)));
IO (main_id = H5Gopen (file_id, "/fclib_global", H5P_DEFAULT));
IO (H5LTread_dataset_int (file_id, "/fclib_global/spacedim", &problem->spacedim));
IO (id = H5Gopen (file_id, "/fclib_global/M", H5P_DEFAULT));
problem->M = read_matrix (id);
IO (H5Gclose (id));
IO (id = H5Gopen (file_id, "/fclib_global/H", H5P_DEFAULT));
problem->H = read_matrix (id);
IO (H5Gclose (id));
if (H5Lexists (file_id, "/fclib_global/G", H5P_DEFAULT))
{
IO (id = H5Gopen (file_id, "/fclib_global/G", H5P_DEFAULT));
problem->G = read_matrix (id);
IO (H5Gclose (id));
}
IO (id = H5Gopen (file_id, "/fclib_global/vectors", H5P_DEFAULT));
read_global_vectors (id, problem);
IO (H5Gclose (id));
if (H5Lexists (file_id, "/fclib_global/info", H5P_DEFAULT))
{
IO (id = H5Gopen (file_id, "/fclib_global/info", H5P_DEFAULT));
problem->info = read_problem_info (id);
IO (H5Gclose (id));
}
IO (H5Gclose (main_id));
IO (H5Fclose (file_id));
return problem;
}
开发者ID:xhub,项目名称:fclib,代码行数:49,代码来源:fclib.c
示例19: zconcatmatrix
/* <matrix1> <matrix2> <matrix> concatmatrix <matrix> */
static int
zconcatmatrix(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gs_matrix m1, m2, mp;
int code;
if ((code = read_matrix(imemory, op - 2, &m1)) < 0 ||
(code = read_matrix(imemory, op - 1, &m2)) < 0 ||
(code = gs_matrix_multiply(&m1, &m2, &mp)) < 0 ||
(code = write_matrix(op, &mp)) < 0
)
return code;
op[-2] = *op;
pop(2);
return code;
}
开发者ID:computersforpeace,项目名称:ghostpdl,代码行数:18,代码来源:zmatrix.c
示例20: sub_font_params
/* Get FontMatrix and FontName parameters. */
static int
sub_font_params(gs_memory_t *mem, const ref *op, gs_matrix *pmat, gs_matrix *pomat, ref *pfname)
{
ref *pmatrix, *pfontname, *pfontstyle, *porigfont, *pfontinfo;
if (dict_find_string(op, "FontMatrix", &pmatrix) <= 0 ||
read_matrix(mem, pmatrix, pmat) < 0
)
return_error(e_invalidfont);
if (dict_find_string(op, "OrigFont", &porigfont) <= 0)
porigfont = NULL;
if (pomat!= NULL) {
if (porigfont == NULL ||
dict_find_string(porigfont, "FontMatrix", &pmatrix) <= 0 ||
read_matrix(mem, pmatrix, pomat) < 0
)
memset(pomat, 0, sizeof(*pomat));
}
/* Use the FontInfo/OrigFontName key preferrentially (created by MS PSCRIPT driver) */
if ((dict_find_string((porigfont != NULL ? porigfont : op), "FontInfo", &pfontinfo) > 0) &&
r_has_type(pfontinfo, t_dictionary) &&
(dict_find_string(pfontinfo, "OrigFontName", &pfontname) > 0)) {
if ((dict_find_string(pfontinfo, "OrigFontStyle", &pfontstyle) > 0) &&
r_size(pfontstyle) > 0) {
const byte *tmpStr1 = pfontname->value.const_bytes;
const byte *tmpStr2 = pfontstyle->value.const_bytes;
int fssize1 = r_size(pfontname), fssize2 = r_size(pfontstyle), fssize = fssize1 + fssize2 + 1;
byte *sfname = gs_alloc_string(mem, fssize, "sub_font_params");
if (sfname == NULL)
return_error(e_VMerror);
memcpy(sfname, tmpStr1, fssize1);
sfname[fssize1]=',' ;
memcpy(sfname + fssize1 + 1, tmpStr2, fssize2);
make_string(pfname, a_readonly, fssize, sfname);
} else
get_font_name(mem, pfname, pfontname);
} else if (dict_find_string((porigfont != NULL ? porigfont : op), ".Alias", &pfontname) > 0) {
/* If we emulate the font, we want the requested name rather than a substitute. */
get_font_name(mem, pfname, pfontname);
} else if (dict_find_string((porigfont != NULL ? porigfont : op), "FontName", &pfontname) > 0) {
get_font_name(mem, pfname, pfontname);
} else
make_empty_string(pfname, a_readonly);
return 0;
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:47,代码来源:zbfont.c
注:本文中的read_matrix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论