void test3() { Matrix m1 = matrix_create( 3, 3 ); int i,j; for ( i=0; i<3; ++i ) { for ( j=0; j<3; ++j ) { m1[i][j] = i+2*j; } } printf( "m1 =\n" ); matrix_print( m1, 3, 3 ); printf( "delete row 0 from m1 =\n" ); matrix_delete_row( m1, 0, 3 ); matrix_print( m1, 2, 3 ); matrix_delete( m1, 2 ); }
void test4() { Matrix m1 = matrix_create( 3, 3 ); int i,j; for ( i=0; i<3; ++i ) { for ( j=0; j<3; ++j ) { m1[i][j] = i+2*j; } } printf( "m1 =\n" ); matrix_print( m1, 3, 3 ); printf( "delete column 1 from m1 =\n" ); matrix_delete_column( m1, 1, 3, 3 ); matrix_print( m1, 3, 2 ); matrix_delete( m1, 3 ); }
/* calculate percent error between A and B in terms of Frobenius norm: 100*norm(A - B)/norm(A) */ double get_percent_error_between_two_mats(mat *A, mat *B){ int m,n; double normA, normB, normA_minus_B; mat *A_minus_B; m = A->nrows; n = A->ncols; A_minus_B = matrix_new(m,n); matrix_copy(A_minus_B, A); matrix_sub(A_minus_B, B); normA = get_matrix_frobenius_norm(A); normB = get_matrix_frobenius_norm(B); normA_minus_B = get_matrix_frobenius_norm(A_minus_B); matrix_delete(A_minus_B); return 100.0*normA_minus_B/normA; }
static void allpairs_compare_SWALIGN( const char *name1, const char *data1, int size1, const char *name2, const char *data2, int size2 ) { char *stra = strdup(data1); char *strb = strdup(data2); stra[size1-1] = 0; strb[size2-1] = 0; struct matrix *m = matrix_create(size1-1,size2-1); struct alignment *aln = align_smith_waterman(m,stra,strb); pthread_mutex_lock(&mutex); printf("> %s %s\n",name1,name2); alignment_print(stdout,stra,strb,aln); pthread_mutex_unlock(&mutex); free(stra); free(strb); matrix_delete(m); alignment_delete(aln); }
void ekf_delete(struct ekf *ekf) { if (ekf) { if (ekf->X) matrix_delete(ekf->X); if (ekf->P) matrix_delete(ekf->P); if (ekf->Q) matrix_delete(ekf->Q); if (ekf->R) matrix_delete(ekf->R); if (ekf->A) matrix_delete(ekf->A); if (ekf->H) matrix_delete(ekf->H); if (ekf->K) matrix_delete(ekf->K); free(ekf); } }
void estimate_rank_and_buildQ2(mat *M, int kblock, double TOL, mat **Y, mat **Q, int *good_rank){ int m,n,i,j,ind,exit_loop = 0; double error_norm; mat *RN,*Y_new,*Y_big,*QtM,*QQtM; vec *vi,*vj,*p,*p1; m = M->nrows; n = M->ncols; // build random matrix printf("form RN..\n"); RN = matrix_new(n,kblock); initialize_random_matrix(RN); // multiply to get matrix of random samples Y printf("form Y: %d x %d..\n",m,kblock); *Y = matrix_new(m, kblock); matrix_matrix_mult(M, RN, *Y); ind = 0; while(!exit_loop){ printf("form Q..\n"); if(ind > 0){ matrix_delete(*Q); } *Q = matrix_new((*Y)->nrows, (*Y)->ncols); QR_factorization_getQ(*Y, *Q); // compute QtM QtM = matrix_new((*Q)->ncols, M->ncols); matrix_transpose_matrix_mult(*Q,M,QtM); // compute QQtM QQtM = matrix_new(M->nrows, M->ncols); matrix_matrix_mult(*Q,QtM,QQtM); error_norm = 0.01*get_percent_error_between_two_mats(QQtM, M); printf("Y is of size %d x %d and error_norm = %f\n", (*Y)->nrows, (*Y)->ncols, error_norm); *good_rank = (*Y)->ncols; // add more samples if needed if(error_norm > TOL){ Y_new = matrix_new(m, kblock); initialize_random_matrix(RN); matrix_matrix_mult(M, RN, Y_new); Y_big = matrix_new((*Y)->nrows, (*Y)->ncols + Y_new->ncols); append_matrices_horizontally(*Y, Y_new, Y_big); matrix_delete(*Y); *Y = matrix_new(Y_big->nrows,Y_big->ncols); matrix_copy(*Y,Y_big); matrix_delete(Y_big); matrix_delete(Y_new); matrix_delete(QtM); matrix_delete(QQtM); ind++; } else{ matrix_delete(RN); exit_loop = 1; } } }
void estimate_rank_and_buildQ(mat *M, double frac_of_max_rank, double TOL, mat **Q, int *good_rank){ int m,n,i,j,ind,maxdim; double vec_norm; mat *RN,*Y,*Qbig,*Qsmall; vec *vi,*vj,*p,*p1; m = M->nrows; n = M->ncols; maxdim = round(min(m,n)*frac_of_max_rank); vi = vector_new(m); vj = vector_new(m); p = vector_new(m); p1 = vector_new(m); // build random matrix printf("form RN..\n"); RN = matrix_new(n, maxdim); initialize_random_matrix(RN); // multiply to get matrix of random samples Y printf("form Y: %d x %d..\n",m,maxdim); Y = matrix_new(m, maxdim); matrix_matrix_mult(M, RN, Y); // estimate rank k and build Q from Y printf("form Qbig..\n"); Qbig = matrix_new(m, maxdim); matrix_copy(Qbig, Y); printf("estimate rank with TOL = %f..\n", TOL); *good_rank = maxdim; int forbreak = 0; for(j=0; !forbreak && j<maxdim; j++){ matrix_get_col(Qbig, j, vj); for(i=0; i<j; i++){ matrix_get_col(Qbig, i, vi); project_vector(vj, vi, p); vector_sub(vj, p); if(vector_get2norm(p) < TOL && vector_get2norm(p1) < TOL){ *good_rank = j; forbreak = 1; break; } vector_copy(p1,p); } vec_norm = vector_get2norm(vj); vector_scale(vj, 1.0/vec_norm); matrix_set_col(Qbig, j, vj); } printf("estimated rank = %d\n", *good_rank); Qsmall = matrix_new(m, *good_rank); *Q = matrix_new(m, *good_rank); matrix_copy_first_columns(Qsmall, Qbig); QR_factorization_getQ(Qsmall, *Q); matrix_delete(RN); matrix_delete(Y); matrix_delete(Qsmall); matrix_delete(Qbig); }
static void ac_update_curve_polygon(struct approximation_curve* ac) { Grille_flottant* m; Grille_flottant* mt; Grille_flottant* mmt; Table_flottant* p; Table_flottant* a; Table_flottant* mp; Table_flottant* params; // Allocation de la table des points de contrôle de la courbe d'approximation if (ac->curve_polygon.nb != (ac->degree + 1)) { free(ac->curve_polygon.table); ac->curve_polygon.nb = ac->degree + 1; ALLOUER(ac->curve_polygon.table, ac->curve_polygon.nb); } // Paramétrisation de la courbe d'approximation if (ac->use_uniform_parameterization) params = ac_uniform_parameterization(&ac->points); else params = ac_non_uniform_parameterization(&ac->points); // Construction de la matrice de Bernstein, de sa transposée et de leur produit m = matrix_create(ac->degree + 1, ac->points.nb); ac_bernstein_matrix(m, params); mt = matrix_transpose(m); mmt = matrix_product(m, mt); // Résolution des 3 systèmes d'équations (composantes x, y et z) des points de contrôle recherchés p = malloc_table_flottant(ac->points.nb); a = malloc_table_flottant(ac->degree + 1); mp = malloc_table_flottant(m->nb_lignes); // X get_triplets_x_values(&ac->points, p); matrix_vector_product(m, p, mp); if (resolution_systeme_lineaire(mmt, mp, a)) EXIT; set_triplets_x_values(&ac->curve_polygon, a); // Y get_triplets_y_values(&ac->points, p); matrix_vector_product(m, p, mp); if (resolution_systeme_lineaire(mmt, mp, a)) EXIT; set_triplets_y_values(&ac->curve_polygon, a); // Z get_triplets_z_values(&ac->points, p); matrix_vector_product(m, p, mp); if (resolution_systeme_lineaire(mmt, mp, a)) EXIT; set_triplets_z_values(&ac->curve_polygon, a); // Libération des ressources matrix_delete(m); matrix_delete(mt); matrix_delete(mmt); free_table_flottant(a); free_table_flottant(p); free_table_flottant(mp); free_table_flottant(params); }
int main() { int i, j, m, n, k, p, q, s, vnum, offset; int64_t frank, numnnz; double val,normM,normU,normS,normV,normP,percent_error; mat *M, *U, *S, *V, *P; struct timeval start_time, end_time; m = 50000; n = 100000; numnnz = m*n; // dense M = matrix_new(m,n); m = M->nrows; n = M->ncols; printf("sizes of M are %d by %d\n", m, n); printf("m*n = %" PRId64 "\n", numnnz); // this is bigger than a 32 bit int can hold printf("initializing random matrix..\n"); gettimeofday(&start_time,NULL); initialize_random_matrix(M); gettimeofday(&end_time,NULL); printf("done loading..\n"); printf("elapsed time: about %4.2f seconds\n", get_seconds_frac(start_time,end_time)); // now test low rank SVD of M.. k = 1000; // rank we want p = 20; // oversampling q = 3; // power scheme s = 1; // re-rotho for power scheme vnum = 1; // scheme to use printf("calling random SVD..\n"); gettimeofday(&start_time,NULL); low_rank_svd_rand_decomp_fixed_rank(M, k, p, vnum, q, s, &frank, &U, &S, &V); gettimeofday(&end_time,NULL); printf("elapsed time: about %4.2f seconds\n", get_seconds_frac(start_time,end_time)); // form product matrix P = matrix_new(m,n); form_svd_product_matrix(U,S,V,P); // get norms of each normM = get_matrix_frobenius_norm(M); normU = get_matrix_frobenius_norm(U); normS = get_matrix_frobenius_norm(S); normV = get_matrix_frobenius_norm(V); normP = get_matrix_frobenius_norm(P); printf("normM = %f ; normU = %f ; normS = %f ; normV = %f ; normP = %f\n", normM, normU, normS, normV, normP); // calculate percent error percent_error = get_percent_error_between_two_mats(M,P); printf("percent_error between M and U S V^T = %f\n", percent_error); // delete and exit printf("delete and exit..\n"); matrix_delete(M); matrix_delete(U); matrix_delete(S); matrix_delete(V); matrix_delete(P); return 0; }
int main(int argc, char ** argv) { FILE * input; struct seq *s1=0, *s2=0; char ori; char c; int fileindex; int del_input=0; while((c = getopt(argc, argv, "a:o:k:m:q:xd:vh")) != (char) -1) { switch (c) { case 'a': align_type = optarg; break; case 'o': output_format = optarg; break; case 'm': min_align = atoi(optarg); break; case 'q': min_qual = atof(optarg); break; case 'x': del_input = 1; break; case 'd': debug_flags_set(optarg); break; case 'v': cctools_version_print(stdout, argv[0]); exit(0); break; default: case 'h': show_help(argv[0]); exit(0); break; } } cctools_version_debug(D_DEBUG, argv[0]); fileindex = optind; if ((argc - optind) == 1) { input = fopen(argv[fileindex], "r"); if (!input) { fprintf(stderr, "sand_align_kernel: couldn't open %s: %s\n",argv[fileindex],strerror(errno)); exit(1); } } else { input = stdin; } struct cseq *c1, *c2; if(!strcmp(output_format,"ovl") || !strcmp(output_format, "ovl_new")) { overlap_write_begin(stdout); } // outer loop: read first sequence in comparison list while((c1=cseq_read(input))) { s1 = cseq_uncompress(c1); cseq_free(c1); // inner loop: read sequences until null (indicating end of list) // then continue again with outer loop. (two nulls to halt.) while((c2=cseq_read(input))) { s2 = cseq_uncompress(c2); cseq_free(c2); int dir = 0; int start1 = 0; int start2 = 0; char* tmp = strdup(s2->metadata); int metadata_valid = 0; char* token = strtok(tmp, " "); start2 = atoi(token); metadata_valid++; while((token = strtok(NULL, " "))) { dir = start1; start1 = start2; start2 = atoi(token); metadata_valid++; } if(metadata_valid>=1 && dir==-1) { seq_reverse_complement(s2); ori = 'I'; } else { ori = 'N'; } struct matrix *m = matrix_create(s1->num_bases,s2->num_bases); if(!m) { fprintf(stderr,"sand_align_kernel: out of memory when creating alignment matrix.\n"); exit(1); } struct alignment *aln; if(!strcmp(align_type,"sw")) { aln = align_smith_waterman(m,s1->data,s2->data); } else if(!strcmp(align_type,"ps")) { aln = align_prefix_suffix(m,s1->data,s2->data, min_align); } else if(!strcmp(align_type,"banded")) { if(metadata_valid<3) { fprintf(stderr,"sand_align_kernel: sequence %s did not indicate start positions for the banded alignment.\n",s2->name); exit(1); } /* The width of the band is proportional to the desired quality of the match. */ int k = 2 + min_qual * MIN(s1->num_bases,s2->num_bases) / 2.0; if(k<5) k = 5; aln = align_banded(m,s1->data, s2->data, start1, start2, k); } else { fprintf(stderr,"unknown alignment type: %s\n",align_type); exit(1); } aln->ori = ori; if(aln->quality <= min_qual) { if(!strcmp(output_format,"ovl")) { overlap_write_v5(stdout, aln, s1->name, s2->name); } else if(!strcmp(output_format, "ovl_new")) { overlap_write_v7(stdout, aln, s1->name, s2->name); } else if(!strcmp(output_format,"matrix")) { printf("*** %s alignment of sequences %s and %s (quality %lf):\n\n",align_type,s1->name,s2->name,aln->quality); matrix_print(m,s1->data,s2->data); } else if(!strcmp(output_format,"align")) { printf("*** %s alignment of sequences %s and %s (quality %lf):\n\n",align_type,s1->name,s2->name,aln->quality); alignment_print(stdout,s1->data,s2->data,aln); } else { printf("unknown output format '%s'\n",output_format); exit(1); } } matrix_delete(m); seq_free(s2); alignment_delete(aln); } seq_free(s1); } fclose(input); if(!strcmp(output_format,"ovl") || !strcmp(output_format, "ovl_new")) { overlap_write_end(stdout); } if ((argc - optind) == 1 && del_input == 1) { remove(argv[fileindex]); } return 0; }
mat matrix_solve_qr(mat xMatrix, mat yMatrix) { mat qr,x,result; double *rDiag,s; int i,n,m,k,j,nx; /* Initial validations */ if (xMatrix->m != yMatrix->m) { printf("Matrix row dimensions must agree.\n"); exit(1); } /* Perform a QR decomp. */ n = xMatrix->n; m = xMatrix->m; rDiag = (double*)calloc(n,sizeof(double)); qr = matrix_copy(xMatrix); // Main loop. for (k = 0; k < n; k++) { // Compute 2-norm of k-th column without under/overflow. double nrm = 0; for (i = k; i < m; i++) { nrm = calc_hypot(nrm, qr->v[i][k]); } if (nrm != 0.0) { // Form k-th Householder vector. if (qr->v[k][k] < 0) { nrm = -nrm; } for (i = k; i < m; i++) { qr->v[i][k] /= nrm; } qr->v[k][k] += 1.0; // Apply transformation to remaining columns. for (j = k + 1; j < n; j++) { s = 0.0; for (i = k; i < m; i++) { s += qr->v[i][k] * qr->v[i][j]; } s = -s / qr->v[k][k]; for (i = k; i < m; i++) { qr->v[i][j] += s * qr->v[i][k]; } } } rDiag[k] = -nrm; } /* Validate */ for(i=0;i<n;i++) { if( fabs(rDiag[i])==0 ) { printf("Matrix is rank deficient. Data fails to converge."); exit(1); } } /* Now solve */ /* Copy right hand side */ nx = yMatrix->n; x = matrix_copy(yMatrix); /* Compute Y = transpose(Q)*B */ for (k = 0; k < n; k++) { for (j = 0; j < nx; j++) { s = 0.0; for (i = k; i < m; i++) { s += qr->v[i][k] * x->v[i][j]; } s = -s / qr->v[k][k]; for (i = k; i < m; i++) { x->v[i][j] += s * qr->v[i][k]; } } } /* Solve R*X = Y; */ for (k = n - 1; k >= 0; k--) { for (j = 0; j < nx; j++) { x->v[k][j] /= rDiag[k]; } for (i = 0; i < k; i++) { for (j = 0; j < nx; j++) { x->v[i][j] -= x->v[k][j] * qr->v[i][k]; } } } /* Build result matrix */ result = matrix_new(n,nx); for(i=0;i<n;i++) { for(j=0;j<nx;j++) { result->v[i][j] = x->v[i][j]; } } /* Cleanup */ matrix_delete(qr); matrix_delete(x); /* Return the result */ return result; }
mat matrix_solve_lu(mat xMatrix, mat yMatrix) { mat lu,x; double s,t; int i,n,m,k,j,nx,kmax,p; int *piv; int pivsign; double *LUrowi; double *LUcolj; /* Initial validations */ if (xMatrix->m != yMatrix->m) { printf("Matrix row dimensions must agree.\n"); exit(1); } // Use a "left-looking", dot-product, Crout/Doolittle algorithm. lu = matrix_copy(xMatrix); m = xMatrix->m; n = xMatrix->n; piv = (int*)calloc(m,sizeof(int)); for (i = 0; i < m; i++) { piv[i] = i; } pivsign = 1; LUcolj = (double*)calloc(m,sizeof(double)); // Outer loop. for (j = 0; j < n; j++) { // Make a copy of the j-th column to localize references. for (i = 0; i < m; i++) { LUcolj[i] = lu->v[i][j]; } // Apply previous transformations. for (i = 0; i < m; i++) { LUrowi = lu->v[i]; // Most of the time is spent in the following dot product. kmax = MIN(i, j); s = 0.0; for (k = 0; k < kmax; k++) { s += LUrowi[k] * LUcolj[k]; } LUrowi[j] = LUcolj[i] -= s; } // Find pivot and exchange if necessary. p = j; for (i = j + 1; i < m; i++) { if (fabs(LUcolj[i]) > fabs(LUcolj[p])) { p = i; } } if (p != j) { for (k = 0; k < n; k++) { t = lu->v[p][k]; lu->v[p][k] = lu->v[j][k]; lu->v[j][k] = t; } k = piv[p]; piv[p] = piv[j]; piv[j] = k; pivsign = -pivsign; } // Compute multipliers. if (j < m && lu->v[j][j] != 0.0) { for (i = j + 1; i < m; i++) { lu->v[i][j] /= lu->v[j][j]; } } } /* Validate */ for(i=0;i<n;i++) { if( lu->v[i][i]==0 ) { printf("Matrix is rank deficient. Data fails to converge."); exit(1); } } /* Now solve */ // Copy right hand side with pivoting nx = yMatrix->n; x = get_matrix(yMatrix,piv,m, 0, nx - 1); // Solve L*Y = B(piv,:) for (k = 0; k < n; k++) { for (i = k + 1; i < n; i++) { for (j = 0; j < nx; j++) { x->v[i][j] -= x->v[k][j] * lu->v[i][k]; } } } // Solve U*X = Y; for (k = n - 1; k >= 0; k--) { for (j = 0; j < nx; j++) { x->v[k][j] /= lu->v[k][k]; } for (i = 0; i < k; i++) { for (j = 0; j < nx; j++) { x->v[i][j] -= x->v[k][j] * lu->v[i][k]; } } } /* Cleanup */ free(piv); free(LUcolj); matrix_delete(lu); return x; }
int main() { int i, j, m, n, k, l, p, q, s, frank, kstep, nstep, culaVersion; double TOL,normM,normU,normS,normV,normP,percent_error,elapsed_secs; mat *M, *T, *S, *C, *U, *R, *Q, *B; vec *Icol, *Irow; time_t start_time, end_time; char *M_file = "../../matrix_data/A_mat_6kx12k.bin"; //char *M_file = "../data/A_mat_2kx4k.bin"; //char *M_file = "../data/A_mat_1kx2k.bin"; //char *M_file = "../data/A_mat_10x8.bin"; struct timeval start_timeval, end_timeval; culaStatus status; printf("Initializing CULA\n"); status = culaInitialize(); checkStatus(status); culaVersion = culaGetVersion(); printf("culaVersion is %d\n", culaVersion); printf("loading matrix from %s\n", M_file); M = matrix_load_from_binary_file(M_file); m = M->nrows; n = M->ncols; printf("sizes of M are %d by %d\n", m, n); printf("norm(M,fro) = %f\n", get_matrix_frobenius_norm(M)); // now test rank k ID of M.. k = 1000; // rank p = 20; // oversampling q = 0; // power scheme power s = 2; // power scheme orthogonalization amount kstep = 500; //block step size nstep = 2; TOL = 0; printf("\ncalling rank %d column ID routine..\n", k); gettimeofday(&start_timeval, NULL); //id_decomp_fixed_rank_or_prec(M, k, 0, &frank, &Icol, &T); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); //use_id_decomp_for_approximation(M, T, Icol, k); printf("\ncalling rank %d old QB routine..\n", k); gettimeofday(&start_timeval, NULL); //randQB_pb(M, kstep, nstep, q, s, &Q, &B); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); //use_QB_decomp_for_approximation(M, Q, B); printf("\ncalling rank %d new QB routine..\n", k); gettimeofday(&start_timeval, NULL); randQB_pb_new(M, kstep, nstep, TOL, q, s, &frank, &Q, &B); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); use_QB_decomp_for_approximation(M, Q, B); printf("\ncalling rank %d block randomized column ID routine..\n", k); p = kstep; // p should be \geq kstep gettimeofday(&start_timeval, NULL); id_blockrand_decomp_fixed_rank_or_prec(M, k, p, TOL, kstep, q, s, &frank, &Icol, &T); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); use_id_decomp_for_approximation(M, T, Icol, k); printf("\ncalling rank %d randomized column ID routine..\n", k); p = kstep; gettimeofday(&start_timeval, NULL); id_rand_decomp_fixed_rank(M, k, p, q, s, &Icol, &T); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); use_id_decomp_for_approximation(M, T, Icol, k); // delete and exit //printf("delete and exit..\n"); //matrix_delete(M); matrix_delete(T); matrix_delete(S); //vector_delete(Icol); vector_delete(Irow); //printf("Shutting down CULA\n"); //culaShutdown(); //return EXIT_SUCCESS; printf("\ncalling rank %d two sided ID routine..\n", k); gettimeofday(&start_timeval, NULL); //id_two_sided_decomp_fixed_rank_or_prec(M, k, TOL, &frank, &Icol, &Irow, &T, &S); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); //use_id_two_sided_decomp_for_approximation(M, T, S, Icol, Irow, k); printf("\ncalling rank %d randomized two sided ID routine..\n", k); p = 20; gettimeofday(&start_timeval, NULL); id_two_sided_rand_decomp_fixed_rank(M, k, p, q, s, &Icol, &Irow, &T, &S); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); use_id_two_sided_decomp_for_approximation(M, T, S, Icol, Irow, k); printf("\ncalling rank %d block randomized two sided ID routine..\n", k); p = kstep; gettimeofday(&start_timeval, NULL); id_two_sided_blockrand_decomp_fixed_rank_or_prec(M, k, p, TOL, kstep, q, s, &frank, &Icol, &Irow, &T, &S); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); use_id_two_sided_decomp_for_approximation(M, T, S, Icol, Irow, k); printf("\ncalling rank %d CUR routine\n", k); gettimeofday(&start_timeval, NULL); //cur_decomp_fixed_rank_or_prec(M, k, TOL, &frank, &C, &U, &R); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); //use_cur_decomp_for_approximation(M, C, U, R); printf("\ncalling rank %d randomized CUR routine\n", k); p = 20; gettimeofday(&start_timeval, NULL); cur_rand_decomp_fixed_rank(M, k, p, q, s, &C, &U, &R); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); use_cur_decomp_for_approximation(M, C, U, R); printf("\ncalling rank %d block randomized CUR routine\n", k); p = kstep; gettimeofday(&start_timeval, NULL); cur_blockrand_decomp_fixed_rank_or_prec(M, k, p, TOL, kstep, q, s, &frank, &C, &U, &R); gettimeofday(&end_timeval, NULL); elapsed_secs = get_seconds_frac(start_timeval,end_timeval); printf("elapsed time is: %4.1f\n", elapsed_secs); printf("check error\n"); use_cur_decomp_for_approximation(M, C, U, R); // delete and exit printf("delete and exit..\n"); matrix_delete(M); matrix_delete(T); matrix_delete(S); vector_delete(Icol); vector_delete(Irow); printf("Shutting down CULA\n"); culaShutdown(); return EXIT_SUCCESS; }