-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprueba_read_matrix.cpp
More file actions
40 lines (31 loc) · 912 Bytes
/
Copy pathprueba_read_matrix.cpp
File metadata and controls
40 lines (31 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <iostream>
#include "nrutilc.h"
#include "iomatrix.h" // aca esta definida readMatrixFromFile mas generica
using namespace std;
// sobrecargada para no tener que pasar el tamaño. si puede poner en un .h aparte
template <class T>
bool readMatrixFromFile(const char* filename, NRMat<T>& matrix)
{
return readMatrixFromFile(filename, matrix, matrix.nrows(), matrix.ncols());
}
int main()
{
const unsigned int n=30001, m=4;
string name("gs_15.dat");
NRMat<double> mat(n, m); // cuidado que la libreria no cheque n, m > 0
if(!readMatrixFromFile(name.c_str(), mat, n, m)) {
cout << "Error al leer " << name << endl;
return -1;
}
for(unsigned int i = 0; i < n; ++i){
for(unsigned int j = 0; j < m; ++j){
printf("%lf\t", mat[i][j]);
}
printf("\n");
}
return 0;
}