From: P.N. on
HI! i dont know how in
C or C++
to fill two or more dimensional matrix (data from file!), necessary data in
a file must be saved in this format:


x x x x or x,x,x,x values may be separated by space or comma.
alghoritm can fill up to 10000 rows. (i needed for numeric alghoritm to
operations at matrixes)

and how save data from matrix to file, from other hand?

adding will be simple i will create matrix of one type and i will add.

but how transpose some matrix?

Sincerly
P.




From: chenchen on
math problem ?

i dont know what you mean

"P.N." <el3ctron(a)klub.chip.pl> ??????????:dva42o$9mk$1(a)ultra60.mat.uni.torun.pl...
> HI! i dont know how in
> C or C++
> to fill two or more dimensional matrix (data from file!), necessary data
> in a file must be saved in this format:
>
>
> x x x x or x,x,x,x values may be separated by space or comma.
> alghoritm can fill up to 10000 rows. (i needed for numeric alghoritm to
> operations at matrixes)
>
> and how save data from matrix to file, from other hand?
>
> adding will be simple i will create matrix of one type and i will add.
>
> but how transpose some matrix?
>
> Sincerly
> P.
>
>
>
>


From: Jim Langston on
"P.N." <el3ctron(a)klub.chip.pl> wrote in message
news:dva42o$9mk$1(a)ultra60.mat.uni.torun.pl...
> HI! i dont know how in
> C or C++
> to fill two or more dimensional matrix (data from file!), necessary data
> in a file must be saved in this format:
>
>
> x x x x or x,x,x,x values may be separated by space or comma.
> alghoritm can fill up to 10000 rows. (i needed for numeric alghoritm to
> operations at matrixes)
>
> and how save data from matrix to file, from other hand?
>
> adding will be simple i will create matrix of one type and i will add.
>
> but how transpose some matrix?

Of course there are ways to do what you want, but your phrasing seems to
indicate that you want to do.

Are you going to be using C or C++? You can do it the same way in both
using fopen and fread but if you're using C++ then ifstream is prefered.

Do you want to save it in space seperated or comma seperated? For this
problem space would probably be better.

And what type of matrix are you having? Is it a simple two dimentional
array of fixed size, pointers to memory with malloc, or C++'s vector
perhaps?

Tell us what langauge you want to use and what you need to use the array for
and maybe we can give more information.


From: P.N. on
> And what type of matrix are you having? Is it a simple two dimentional
> array of fixed size, pointers to memory with malloc, or C++'s vector
> perhaps?
>
> Tell us what langauge you want to use and what you need to use the array
> for and maybe we can give more information.

generally i need
Adding, subtracting, transpose,and determinant.

my procject in C according simple arthimetic operations looks that:

#include <stdio.h> //matr.c
#include<conio.h>

void main(){

const rows=2;
const columns=3;
float matrixA[rows][columns];
float matrixB[rows][columns];
float matrixC[rows][columns];
int i,j;

FILE *fileA;
FILE *fileB;
FILE *result;

fileA=fopen("c:\\fileA.txt","rt");

for(i=0;i<rows;i++) {
for(j=0;j<columns;j++)
{matrixA[i][j]=0.0;
matrixB[i][j]=0.0;
matrixC[i][j]=0.0;};};

for(i=0;i<rows;i++){
for(j=0;j<columns;j++)

fscanf(fileA,"%f ", &matrixA[i][j]);};


fileB=fopen("c:\\fileB.txt", "rt");

for(i=0;i<rows;i++){
for(j=0;j<columns;j++)

fscanf(fileB,"%f ", &matrixB[i][j]);};

//+(&-)

for(i=0;i<rows;i++){
for(j=0;j<columns;j++)

matrixC[i][j]=matrixA[i][j]+matrixB[i][j];
;};


//show matrix C


for(i=0;i<rows;i++){
for(j=0;j<columns;j++)

printf("%f ", matrixC[i][j]);

printf("\n");};

//save result to file

result=fopen("c:\\result.txt","wt");
for(i=0;i<rows;i++){
for(j=0;j<columns;j++)

fprintf(result,"%f ", matrixC[i][j]);
fprintf(result,"\n");};

fclose(fileA);
fclose(fileB);
fclose(result);


}
-----------------

how will be look comparision cols with rows other matrix? in multiplication



From: Jim Langston on
"P.N." <el3ctron(a)klub.chip.pl> wrote in message
news:dveage$77n$1(a)ultra60.mat.uni.torun.pl...
>> And what type of matrix are you having? Is it a simple two dimentional
>> array of fixed size, pointers to memory with malloc, or C++'s vector
>> perhaps?
>>
>> Tell us what langauge you want to use and what you need to use the array
>> for and maybe we can give more information.
>
> generally i need
> Adding, subtracting, transpose,and determinant.
>
> my procject in C according simple arthimetic operations looks that:
>
> #include <stdio.h> //matr.c
> #include<conio.h>
>
> void main(){
>
> const rows=2;
> const columns=3;
> float matrixA[rows][columns];
> float matrixB[rows][columns];
> float matrixC[rows][columns];
> int i,j;
>
> FILE *fileA;
> FILE *fileB;
> FILE *result;
>
> fileA=fopen("c:\\fileA.txt","rt");
>
> for(i=0;i<rows;i++) {
> for(j=0;j<columns;j++)
> {matrixA[i][j]=0.0;
> matrixB[i][j]=0.0;
> matrixC[i][j]=0.0;};};
>
> for(i=0;i<rows;i++){
> for(j=0;j<columns;j++)
>
> fscanf(fileA,"%f ", &matrixA[i][j]);};
>
>
> fileB=fopen("c:\\fileB.txt", "rt");
>
> for(i=0;i<rows;i++){
> for(j=0;j<columns;j++)
>
> fscanf(fileB,"%f ", &matrixB[i][j]);};
>
> //+(&-)
>
> for(i=0;i<rows;i++){
> for(j=0;j<columns;j++)
>
> matrixC[i][j]=matrixA[i][j]+matrixB[i][j];
> ;};
>
>
> //show matrix C
>
>
> for(i=0;i<rows;i++){
> for(j=0;j<columns;j++)
>
> printf("%f ", matrixC[i][j]);
>
> printf("\n");};
>
> //save result to file
>
> result=fopen("c:\\result.txt","wt");
> for(i=0;i<rows;i++){
> for(j=0;j<columns;j++)
>
> fprintf(result,"%f ", matrixC[i][j]);
> fprintf(result,"\n");};
>
> fclose(fileA);
> fclose(fileB);
> fclose(result);
>
>
> }
> -----------------
>
> how will be look comparision cols with rows other matrix? in
> multiplication

Well, it looks to me like you have a working program there (although I
didn't test it) so what is your question? It looks like you know how to
load and save the matrixes.

I'm not sure what you're asking for, because you ask how to do something,
then give the code doing what you asked to do.