Matrix routines implementation.
More...
Go to the source code of this file.
|
int | MatInit (Mat *A, int m, int nnz, int *indices, double *values, int flag #ifdef W_MPI, MPI_Comm comm #endif) |
|
void | MatSetIndices (Mat *A, int m, int nnz, int *indices) |
|
void | MatSetValues (Mat *A, int m, int nnz, double *values) |
|
void | CommInfo (Mat *A) |
|
void | MatReset (Mat *A) |
|
void | MatFree (Mat *A) |
|
int | MatLoad (Mat *mat, char *filename) |
|
int | MatSave (Mat *mat, char *filename) |
|
int | MatLocalShape (Mat *A, int sflag) |
|
int | MatComShape (Mat *A, int flag, MPI_Comm comm) |
|
int | MatVecProd (Mat *A, double *x, double *y, int pflag) |
|
int | TrMatVecProd_Naive (Mat *A, double *y, double *x, int pflag) |
|
int | TrMatVecProd (Mat *A, double *y, double *x, int pflag) |
|
int | MatInfo (Mat *mat, int verbose, char *filename) |
| Print information about a matrix.
Usefull function to check, debug or bench. It prints matrix array sizes. More...
|
|
int | greedyreduce (Mat *A, double *x) |
|
Matrix routines implementation.
- Note
- Copyright (c) 2010-2012 APC CNRS Université Paris Diderot. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/lgpl.html
-
For more information about ANR MIDAS'09 project see http://www.apc.univ-paris7.fr/APC_CS/Recherche/Adamis/MIDAS09/index.html
-
ACKNOWLEDGMENT: This work has been supported in part by the French National Research Agency (ANR) through COSINUS program (project MIDAS no. ANR-09-COSI-009).
- Author
- Pierre Cargemel
- Date
- November 2011
Definition in file mapmat.c.
◆ MatInit()
int MatInit |
( |
Mat * |
A, |
|
|
int |
m, |
|
|
int |
nnz, |
|
|
int * |
indices, |
|
|
double * |
values, |
|
|
int flag #ifdef |
W_MPI, |
|
|
MPI_Comm comm # |
endif |
|
) |
| |
Create a matrix specifying the number of local rows m, the number of non-zero elements per row nnz , indices tab, values tab, ts_flags tab, flag for communication and a communicator comm. indices and values tabs must be allocated and contain at least m*nnz elements. It represents column indices of the nonzero elements. Respectively values tab represents the non-zero values. After call MatInit, all precomputation are done and the matrix structure is ready to use. That means you can start applying matrix operation. Another way to initialize a matrix structure is to apply step by step :
- MatSetIndices
- MatSetValues
- MatLocalShape
- MatComShape
- Warning
- do not modify indices tab until you will use the matrix structure.
-
[MPI COMM!] with Midapack sequential version, there is no communicator argument.
- Parameters
-
A | pointer to a Mat struct |
m | number of local rows |
nnz | number of non-zero per row |
indices | input tab (modified) |
values | input tab |
flag | communication flag |
comm | MPI communicator |
- See also
- MatFree
Definition at line 54 of file mapmat.c.
◆ MatSetIndices()
void MatSetIndices |
( |
Mat * |
A, |
|
|
int |
m, |
|
|
int |
nnz, |
|
|
int * |
indices |
|
) |
| |
Set column indices of the nonzero elements. indices tab must be allocated and contains at least m*nnz elements.
- Parameters
-
A | pointer to a Mat struct |
m | number of local rows |
nnz | number of non-zero per row |
indices | input tab |
- Returns
- void
Definition at line 83 of file mapmat.c.
◆ MatSetValues()
void MatSetValues |
( |
Mat * |
A, |
|
|
int |
m, |
|
|
int |
nnz, |
|
|
double * |
values |
|
) |
| |
Set values of the nonzero elements. values tab must be allocated and contains at least m*nnz values.
- Parameters
-
A | pointer to a Mat struct |
m | number of local rows |
nnz | number of non-zero per row |
values | input tab |
- Returns
- void
Definition at line 97 of file mapmat.c.
◆ CommInfo()
◆ MatReset()
◆ MatFree()
Free allocated tabs of a matrix structure including local indices tab and communication tabs. Do not free indices and values which user is responsible for.
- Parameters
-
- Returns
- void
- See also
- MatInit MatLocalShape
Definition at line 323 of file mapmat.c.
◆ MatLoad()
int MatLoad |
( |
Mat * |
mat, |
|
|
char * |
filename |
|
) |
| |
Load matrix from a file. This is MatSave dual routine which loads data into matrix reading a specified file (or several specified files). Number of files should equal number of processor. File format should be ascii files (for examples look at files generated by MapMatSave routine).
- Warning
- Does not include gap samples flags functionality
- Todo:
- Implement to read several file formats as basic ASCII, XML, HDF5...
- Parameters
-
mat | pointer to the Mat |
filename | basename of a file, actually data are loaded from several files denotes by "basename + processor number" |
- Returns
- error code
Definition at line 414 of file mapmat.c.
◆ MatSave()
int MatSave |
( |
Mat * |
mat, |
|
|
char * |
filename |
|
) |
| |
Write matrix into files This is the dual routine of MatLoad. It saves matrix data into files, and can be usefull to check that data are well stored. Obviously it performs IO, moreover with one file per processor. Therfore, just call this function in a development phase, with few data and few processors.
- Warning
- Does not include gap samples flags functionality.
- Parameters
-
A | pointer to the Mat |
filename | file basename, for instance passing "toto" should produce the output files named "toto_$(rank)" |
- Returns
- error code
Definition at line 460 of file mapmat.c.
◆ MatLocalShape()
int MatLocalShape |
( |
Mat * |
A, |
|
|
int |
sflag |
|
) |
| |
Compute a local indices into a dense vector, lindices, and reindices indices tab according the this local dense vector. For this three steps are performed :
- sort and merge indices tab,
- allocate lindices of size lcount and copy the sorted indices
- reindex indices according the local indices
- Warning
- lindices is internally allocated ( to free it, use MatFree )
- See also
- MatComShape MatFree MatSetIndices
Definition at line 496 of file mapmat.c.
◆ MatComShape()
int MatComShape |
( |
Mat * |
A, |
|
|
int |
flag, |
|
|
MPI_Comm |
comm |
|
) |
| |
Transform the matrix data structure, identifying columns shared by several processors
- Warning
- [MPI ONLY!] this function does not exist in Midapack sequential version
- See also
- MatLocalShape MatInit TrMatVecProd
Definition at line 530 of file mapmat.c.
◆ MatVecProd()
int MatVecProd |
( |
Mat * |
A, |
|
|
double * |
x, |
|
|
double * |
y, |
|
|
int |
pflag |
|
) |
| |
Perform matrix-vector multiplication, .
- Parameters
-
A | pointer to a Mat |
x | input vector (overlapped) |
y | output vector (distributed) |
Definition at line 704 of file mapmat.c.
◆ TrMatVecProd_Naive()
int TrMatVecProd_Naive |
( |
Mat * |
A, |
|
|
double * |
y, |
|
|
double * |
x, |
|
|
int |
pflag |
|
) |
| |
Perform transposed matrix-vector multiplication, . This naive version does not require a precomputed communication structure. But communication volumes may be significant. Consequently in most of the cases is not optimized.
- Warning
- [MPI ONLY!] this function does not exist in Midapack sequential version
- See also
- TrMatVecProd MatLocalShape
- Parameters
-
mat | pointer |
y | local input vector (distributed) |
x | local output vector (overlapped) |
Definition at line 744 of file mapmat.c.
◆ TrMatVecProd()
int TrMatVecProd |
( |
Mat * |
A, |
|
|
double * |
y, |
|
|
double * |
x, |
|
|
int |
pflag |
|
) |
| |
Perform a transposed matrix-vector multiplication, using a precomputed communication scheme. Before calling this routine, the communication structure should have been set, calling MatInit or MatComShape. The routine can be divided in two steps :
- a local matrix vector multiplication
- a collective-reduce. it consits in a sum reduce over all processes.
The collective reduce is performed using algorithm previously defined : ring, butterfly ...
- See also
- MatVecProd MatComShape TrMatVecProd_Naive MatInit
- Parameters
-
A | a pointer to a Mat |
y | local input vector (distributed) |
x | local output vector (overlapped) |
Definition at line 819 of file mapmat.c.
◆ MatInfo()
int MatInfo |
( |
Mat * |
mat, |
|
|
int |
verbose, |
|
|
char * |
filename |
|
) |
| |
Print information about a matrix.
Usefull function to check, debug or bench. It prints matrix array sizes.
- See also
- MatSave
- Parameters
-
Definition at line 867 of file mapmat.c.
◆ greedyreduce()
int greedyreduce |
( |
Mat * |
A, |
|
|
double * |
x |
|
) |
| |