zekaleon
April 4th, 2008, 08:48 AM
I've searched the internet for some usefull guide, but I haven't found anything.
In short, I have to read a matrix of doubles from a text file. But I have to use .NET API or at least I have to use OpenFileDialog.
My native code that works just fine for a console version of a program I make:
int i, j, m, n, p, q;
double *picture = 0;
double *kernel = 0;
...
ifstream inFilePicture, inFileKernel;
inFilePicture.open(argv[1], ios::in);
inFileKernel.open(argv[2], ios::in);
//Picture matrix dimension
inFilePicture>>m;
inFilePicture>>n;
//Kernel matrix dimension
inFileKernel>>p;
inFileKernel>>q;
picture = new double[m*n];
kernel = new double[p*q];
//reading matrices from .txt files
for(i=0; i<m; i++)
for(j=0; j<n; j++)
inFilePicture>>picture[i*n+j];
for(i=0; i<p; i++)
for(j=0; j<q; j++)
inFileKernel>>kernel[i*q+j];
I just don't know how to do this with .NET streams. I don't know how to parse a txt file for doubles arranged like this:
dimx
dimy
a11 ...a1,dimy
.
.
.
adimx,1...adimx, dimy
Or without the first two lines (dimx and dimy).
In short, I have to read a matrix of doubles from a text file. But I have to use .NET API or at least I have to use OpenFileDialog.
My native code that works just fine for a console version of a program I make:
int i, j, m, n, p, q;
double *picture = 0;
double *kernel = 0;
...
ifstream inFilePicture, inFileKernel;
inFilePicture.open(argv[1], ios::in);
inFileKernel.open(argv[2], ios::in);
//Picture matrix dimension
inFilePicture>>m;
inFilePicture>>n;
//Kernel matrix dimension
inFileKernel>>p;
inFileKernel>>q;
picture = new double[m*n];
kernel = new double[p*q];
//reading matrices from .txt files
for(i=0; i<m; i++)
for(j=0; j<n; j++)
inFilePicture>>picture[i*n+j];
for(i=0; i<p; i++)
for(j=0; j<q; j++)
inFileKernel>>kernel[i*q+j];
I just don't know how to do this with .NET streams. I don't know how to parse a txt file for doubles arranged like this:
dimx
dimy
a11 ...a1,dimy
.
.
.
adimx,1...adimx, dimy
Or without the first two lines (dimx and dimy).