00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00041 #include "matrix_typedefs.h"
00042 #include "realtype.h"
00043 #include "matrix_utilities.h"
00044 #include "integral_matrix_wrappers.h"
00045 #include "SizesAndBlocks.h"
00046 #include "Matrix.h"
00047 #include "Vector.h"
00048 #include "MatrixSymmetric.h"
00049 #include "MatrixTriangular.h"
00050 #include "MatrixGeneral.h"
00051 #include "VectorGeneral.h"
00052 #include "output.h"
00053
00054 #include "files_dense.h"
00055 #include "files_sparse.h"
00056
00057 #include <iostream>
00058 #include <fstream>
00059 #include <sstream>
00060 #include <string.h>
00061
00062
00063 using namespace std;
00064
00065
00066
00067 typedef intervalType IntervalType;
00068 typedef symmMatrix MatrixTypeInner;
00069 typedef triangMatrix TriangMatrixType;
00070 typedef normalMatrix MatrixGeneral;
00071
00072 typedef std::vector<int> VectorTypeInt;
00073
00074 #define MAX_DOUBLE std::numeric_limits<real>::max()
00075 #define MIN_DOUBLE std::numeric_limits<real>::min()
00076
00077
00078 #define PI 3.14159265 // needed for sprandsym
00079
00080
00081 void print_matrix(std::vector<ergo_real> const &A);
00082 template<typename Matrix>
00083 void init_matrix(Matrix &X, const int N, int blockSizesMultuple = 4);
00084 void get_random_matrix(int N, MatrixTypeInner &X);
00085 void get_all_eigenvalues_of_matrix(std::vector<ergo_real> & eigvalList, const MatrixTypeInner & M);
00086 void sprandsym(int N, MatrixTypeInner &X, MatrixGeneral &Q, vector<ergo_real> &D, const double MATRIX_SPARSITY);
00087 int get_matrix_from_sparse(char *filename, MatrixTypeInner &X);
00088 int get_matrix_from_sparse_vec(char *filename, std::vector<int> &I, std::vector<int> &J, std::vector<real> &val);
00089 int get_matrix_from_binary(char *filename, MatrixTypeInner &X);
00090 int get_matrix_from_binary_vec(char *filename, std::vector<int> &I, std::vector<int> &J, std::vector<real> &val, int &N);
00091 int get_matrix_from_full(char * filename, MatrixTypeInner &X);
00092
00093
00099 template<typename Matrix>
00100 void init_matrix(Matrix &X, const int N, int blockSizesMultuple )
00101 {
00102
00103 int size = N;
00104 int nlevels = 5;
00105 std::vector<int> blockSizes(nlevels);
00106 blockSizes[nlevels - 1] = 1;
00107 for (int ind = nlevels - 2; ind >= 0; ind--)
00108 blockSizes[ind] = blockSizes[ind + 1] * blockSizesMultuple;
00109 mat::SizesAndBlocks rows(blockSizes, size);
00110 mat::SizesAndBlocks cols(blockSizes, size);
00111
00112 X.resetSizesAndBlocks(rows,cols);
00113 }