Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Beta/Math/Vector/NotDone/Gauss/test_sm.cpp File Reference

#include <time.h>
#include <iostream>
#include "Ludecomp.h"

Go to the source code of this file.

Functions

void main ()


Function Documentation

void main void   
 

Definition at line 8 of file test_sm.cpp.

00009 {
00010   int i, j, k, n = 2000, n2 = n * n, t0, t = 0;
00011 
00012   double *A = (double *) malloc(n2 * sizeof(double));
00013 
00014   double *a[4096], x[4096], e; a[0] = A;
00015 
00016   for (i = 1; i < n; i++) a[i] = a[i-1] + n;
00017 
00018   srand(clock());
00019 
00020   for (i = 0; i < n2; i++) A[i] = 0.0;
00021 
00022   for (i = 0; i < n; i++) a[i][i] = 1.0;
00023 
00024   for (k = n; k < 6000; k++)
00025     {
00026       do i = rand() * n / 32768, j = rand() * n / 32768; while (i <= j || a[i][j]);
00027 
00028       a[i][j] = (1 + rand()) / 32768.0;
00029     }
00030 
00031   for (k = 0; k < n2; k++)
00032     {
00033       i = rand() * n / 32768; j = rand() * n / 32768;
00034 
00035       e = a[i][j]; a[i][j] = a[j][i]; a[j][i] = e;
00036     }
00037 
00038   for (k = i = 0; i < n; i++) for (j = 0; j < n; j++) if (a[i][j]) k++;
00039 
00040   printf("k = %d\n", k);
00041 
00042   for (i = 0; i < n; i++) x[i] = rand() / 32767.0;
00043 
00044   smatrix<double> sA(A, n, n), sx(x, n, 1), sb = sA * sx;
00045 
00046   t0 = clock();
00047   TLUDecomp<double> LU(sA, true); sb = LU.Solve(sb);
00048   t += clock() - t0;
00049 
00050   e = (sb - sx).maxCoef;
00051 
00052   printf("Error = %e, Time = %d\n", e, t);
00053 
00054   free(A);
00055 }


Generated on Sun Oct 14 18:47:00 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001