Rariusz
08-23-2009, 05:03 AM
Hallo
I have the code:
#include <stdio.h>
#include <stdlib.h>
#define NN 4
#include "nrutil.h"
#include "nr.h"
int main(int argc, char *argv[])
{
float **M1=matrix(1,NN,1,NN);
int *M2=ivector(1,NN);
float A;
int j,i;
for(i=1;i<NN;i++){
for(j=1;j< NN;j++){
printf("Wprowadz element [%d %d]macierzy ",i,j);
scanf("%f",&(M1[i][j]));
}
}
for(i=1;i<NN;i++){
for(j=1;j<NN;j++){
printf("%f\t",M1[i][j]);
}
printf("\n");
}
ludcmp(M1,NN,M2,&A);
printf("\n");
for(i=1;i<NN;i++){
for(j=1;j<NN;j++){
printf("%f\t",M1[i][j]);
}
printf("\n");
}
free_matrix(M1,1,NN,1,NN);
free_ivector(M2,1,NN);
system("PAUSE");
return 0;
}
matrix:
2.000000 34.000000 3.000000
23.000000 44.000000 55.000000
23.000000 98.000000 34.000000
then:
ludcmp(M1,NN,M2,&A);
I have:
462002186468332547000000000000.000000 0.00000 697762776322846200000000000.00000
0.000000 44.00000 54.999653
0.000000 0.772727 -39.4999763
Where is the mistake?
=======================
Rariusz PL
I have the code:
#include <stdio.h>
#include <stdlib.h>
#define NN 4
#include "nrutil.h"
#include "nr.h"
int main(int argc, char *argv[])
{
float **M1=matrix(1,NN,1,NN);
int *M2=ivector(1,NN);
float A;
int j,i;
for(i=1;i<NN;i++){
for(j=1;j< NN;j++){
printf("Wprowadz element [%d %d]macierzy ",i,j);
scanf("%f",&(M1[i][j]));
}
}
for(i=1;i<NN;i++){
for(j=1;j<NN;j++){
printf("%f\t",M1[i][j]);
}
printf("\n");
}
ludcmp(M1,NN,M2,&A);
printf("\n");
for(i=1;i<NN;i++){
for(j=1;j<NN;j++){
printf("%f\t",M1[i][j]);
}
printf("\n");
}
free_matrix(M1,1,NN,1,NN);
free_ivector(M2,1,NN);
system("PAUSE");
return 0;
}
matrix:
2.000000 34.000000 3.000000
23.000000 44.000000 55.000000
23.000000 98.000000 34.000000
then:
ludcmp(M1,NN,M2,&A);
I have:
462002186468332547000000000000.000000 0.00000 697762776322846200000000000.00000
0.000000 44.00000 54.999653
0.000000 0.772727 -39.4999763
Where is the mistake?
=======================
Rariusz PL