Skip to content

Commit

Permalink
Add method to print Transposed Mtx
Browse files Browse the repository at this point in the history
  • Loading branch information
nottu committed Oct 8, 2017
1 parent 9394541 commit eb25bd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void multMatrizVect(double **mat, double *vec, int n, int m, double* res){
//other
void printVect(double * a, int n){
for (int i = 0; i < n; ++i) {
if(a[i] > 0) printf(" ");
if(a[i] >= 0) printf(" ");
printf("%3.3lf ", a[i]);
}
printf("\n");
Expand All @@ -81,6 +81,15 @@ void printMtx(double**a, int nr, int nc){
printVect(a[i], nc);
}
}
void printMtxT(double**a, int nr, int nc){
for (int i = 0; i < nc; ++i) {
for (int j = 0; j < nr; ++j) {
if(a[j][i] >= 0) printf(" ");
printf("%3.3lf ", a[j][i]);
}
printf("\n");
}
}

double *readVector(char* name, int* sz){
FILE *f = fopen(name, "rb");
Expand Down
1 change: 1 addition & 0 deletions matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void multMatriz(double **mat1, double **mat2, int n, int m, int p, int q, do
//
void printVect(double *a, int n);
void printMtx(double **a, int nr, int nc);
void printMtxT(double **a, int nr, int nc);
//
double* readVector(char* name, int* sz);
double** readMtx(char* name, int* nr, int* nc);
Expand Down

0 comments on commit eb25bd0

Please sign in to comment.