HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
bandedmatrix.h File Reference

Data structure and some function declarations for banded block matrices. More...

Go to the source code of this file.

Data Structures

struct  BandedMatrix
 Structure for defining a banded block matrix. More...
 

Functions

int BandedMatrixDestroy (void *)
 
int BandedMatrixInitialize (void *)
 
int BandedMatrixPreallocate (void *, int, int, int)
 

Detailed Description

Data structure and some function declarations for banded block matrices.

Author
Debojyoti Ghosh

Definition in file bandedmatrix.h.


Data Structure Documentation

struct BandedMatrix

Structure for defining a banded block matrix.

This structure contains all the variables for defining a banded block matrix.

Definition at line 18 of file bandedmatrix.h.

Data Fields
int nbands

number of block bands

int nrows_local

number of block rows (local)

int BlockSize

block size

int * ncol

global column numbers for each block

int * nrow

global row numbers for each block

double * data

array containing the matrix elements

Function Documentation

int BandedMatrixDestroy ( void *  A)

Destroy a banded block matrix object

Free up allocations inside a banded matrix object

Parameters
ABanded matrix object of type BandedMatrix

Definition at line 10 of file BandedMatrixDestroy.c.

11 {
12  BandedMatrix *B = (BandedMatrix*) A;
13 
14  if (B->ncol) free(B->ncol);
15  if (B->nrow) free(B->nrow);
16  if (B->data) free(B->data);
17 
18  return(0);
19 }
double * data
Definition: bandedmatrix.h:24
Structure for defining a banded block matrix.
Definition: bandedmatrix.h:18
int BandedMatrixInitialize ( void *  A)

Initialize a banded block matrix object

Initialize a newly-created banded matrix object.

Parameters
ABanded matrix object of type BandedMatrix

Definition at line 10 of file BandedMatrixInitialize.c.

11 {
12  BandedMatrix *B = (BandedMatrix*) A;
13 
14  B->nbands = 0;
15  B->nrows_local = 0;
16  B->BlockSize = 0;
17 
18  B->ncol = NULL;
19  B->nrow = NULL;
20  B->data = NULL;
21 
22  return(0);
23 }
double * data
Definition: bandedmatrix.h:24
Structure for defining a banded block matrix.
Definition: bandedmatrix.h:18
int BandedMatrixPreallocate ( void *  A,
int  nbands,
int  nrows_local,
int  BlockSize 
)

Preallocate memory for a banded block matrix

Preallocate memory for a banded matrix object.

Parameters
ABanded matrix object of the type BandedMatrix
nbandsNumber of bands
nrows_localLocal number of rows
BlockSizeBlock size

Definition at line 10 of file BandedMatrixPreallocate.c.

16 {
17  BandedMatrix *B = (BandedMatrix*) A;
18 
19  B->nbands = nbands;
20  B->nrows_local = nrows_local;
21  B->BlockSize = BlockSize;
22 
23  B->ncol = (int*) calloc (nrows_local*nbands, sizeof(int));
24  B->nrow = (int*) calloc (nrows_local, sizeof(int));
25  B->data = (double*) calloc (nrows_local*nbands*BlockSize*BlockSize, sizeof(double));
26 
27  return(0);
28 }
double * data
Definition: bandedmatrix.h:24
Structure for defining a banded block matrix.
Definition: bandedmatrix.h:18