127 lines
5.9 KiB
C
127 lines
5.9 KiB
C
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||
|
/* ******** *** SparseLib++ */
|
||
|
/* ******* ** *** *** *** v. 1.5c */
|
||
|
/* ***** *** ******** ******** */
|
||
|
/* ***** *** ******** ******** R. Pozo */
|
||
|
/* ** ******* *** ** *** *** K. Remington */
|
||
|
/* ******** ******** A. Lumsdaine */
|
||
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||
|
/* */
|
||
|
/* */
|
||
|
/* SparseLib++ : Sparse Matrix Library */
|
||
|
/* */
|
||
|
/* National Institute of Standards and Technology */
|
||
|
/* University of Notre Dame */
|
||
|
/* Authors: R. Pozo, K. Remington, A. Lumsdaine */
|
||
|
/* */
|
||
|
/* NOTICE */
|
||
|
/* */
|
||
|
/* Permission to use, copy, modify, and distribute this software and */
|
||
|
/* its documentation for any purpose and without fee is hereby granted */
|
||
|
/* provided that the above notice appear in all copies and supporting */
|
||
|
/* documentation. */
|
||
|
/* */
|
||
|
/* Neither the Institutions (National Institute of Standards and Technology, */
|
||
|
/* University of Notre Dame) nor the Authors make any representations about */
|
||
|
/* the suitability of this software for any purpose. This software is */
|
||
|
/* provided ``as is'' without expressed or implied warranty. */
|
||
|
/* */
|
||
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||
|
|
||
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||
|
/* Compressed column sparse matrix (O-based, Fortran) */
|
||
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||
|
|
||
|
|
||
|
#ifndef CompCol_Mat_double_H
|
||
|
#define CompCol_Mat_double_H
|
||
|
|
||
|
//#include "vecdefs.h"
|
||
|
#include "vecdefs_GR.h" // modif GR
|
||
|
//#include VECTOR_H // modif GR
|
||
|
|
||
|
class CompRow_Mat_double;
|
||
|
class Coord_Mat_double;
|
||
|
|
||
|
class CompCol_Mat_double {
|
||
|
|
||
|
// private:
|
||
|
protected : // modif GR
|
||
|
VECTOR_double val_; // data values (nz_ elements)
|
||
|
VECTOR_int rowind_; // row_ind (nz_ elements)
|
||
|
VECTOR_int colptr_; // col_ptr (dim_[1]+1 elements)
|
||
|
|
||
|
int base_; // index base: offset of first element
|
||
|
int nz_; // number of nonzeros
|
||
|
int dim_[2]; // number of rows, cols
|
||
|
|
||
|
public:
|
||
|
CompCol_Mat_double(void);
|
||
|
CompCol_Mat_double(const CompCol_Mat_double &S);
|
||
|
CompCol_Mat_double(const CompRow_Mat_double &R);
|
||
|
CompCol_Mat_double(const Coord_Mat_double &CO);
|
||
|
// constructeur parmettant la création d'une matrice creuse
|
||
|
// M : nombre de lignes
|
||
|
// N : nombre de colonnes
|
||
|
// nz : le nombre de valeurs non nulles
|
||
|
// val : le vecteur qui contiend les données non nulles, sous forme
|
||
|
// de la suite des colonnes
|
||
|
// r : la suite des numéros de position des valeurs non nulles
|
||
|
// dans les différentes colonnes
|
||
|
// c : les numéros dans r de chaque début de colonne + le numéro
|
||
|
// du dernier élément c-a-d nz
|
||
|
// base : indique si la matrice est une copie ou non d'une autre matrice
|
||
|
CompCol_Mat_double(int M, int N, int nz, double *val, int *r,
|
||
|
int *c, int base=0);
|
||
|
CompCol_Mat_double(int M, int N, int nz, const VECTOR_double &val,
|
||
|
const VECTOR_int &r, const VECTOR_int &c,
|
||
|
int base=0);
|
||
|
~CompCol_Mat_double() {};
|
||
|
|
||
|
/*******************************/
|
||
|
/* Access and info functions */
|
||
|
/*******************************/
|
||
|
|
||
|
double& val(int i) { return val_(i); }
|
||
|
int& row_ind(int i) { return rowind_(i); }
|
||
|
int& col_ptr(int i) { return colptr_(i);}
|
||
|
|
||
|
const double& val(int i) const { return val_(i); }
|
||
|
const int& row_ind(int i) const { return rowind_(i); }
|
||
|
const int& col_ptr( int i) const { return (colptr_(i));}
|
||
|
|
||
|
int dim(int i) const {return dim_[i];};
|
||
|
int size(int i) const {return dim_[i];};
|
||
|
int NumNonzeros() const {return nz_;};
|
||
|
int base() const {return base_;}
|
||
|
/*******************************/
|
||
|
/* Assignment operator */
|
||
|
/*******************************/
|
||
|
|
||
|
CompCol_Mat_double& operator=(const CompCol_Mat_double &C);
|
||
|
CompCol_Mat_double& newsize(int M, int N, int nz);
|
||
|
|
||
|
/***********************************/
|
||
|
/* General access function (slow) */
|
||
|
/***********************************/
|
||
|
double operator() (int i, int j) const;
|
||
|
double& set(int i, int j);
|
||
|
/* ajout GR */
|
||
|
bool Exista(int i, int j) const;
|
||
|
|
||
|
/***********************************/
|
||
|
/* Matrix/Vector multiply */
|
||
|
/***********************************/
|
||
|
|
||
|
VECTOR_double operator*(const VECTOR_double &x) const;
|
||
|
VECTOR_double trans_mult(const VECTOR_double &x) const;
|
||
|
|
||
|
};
|
||
|
|
||
|
ostream& operator << (ostream & os, const CompCol_Mat_double & mat);
|
||
|
void readHB(const char *, CompCol_Mat_double &);
|
||
|
|
||
|
#endif
|
||
|
/* CompCol_Mat_double_H */
|
||
|
|