17#include "spm_drivers.h"
18#include "drivers/laplacian.h"
30 "Usage: genLaplacian( \"[<type>:]<dim1>[:<dim2>[:<dim3>[:<alpha>[:<beta>[:<dof>]]]]]\" )\n"
31 " Generate a Laplacian matrix M, of the form alpha * D - beta * A,\n"
32 " where D is the degree matrix, and A the adjacency matrix.\n"
33 " <type> p = pattern only\n"
35 " d = real double [default]\n"
36 " c = complex simple\n"
37 " z = complex double\n"
38 " <dim1> size of the first dimension of the laplacian\n"
39 " <dim2> size of the second dimension of the laplacian\n"
40 " <dim3> size of the third dimension of the laplacian\n"
41 " <dof> size of the dof parameter to generate multi-dof matrices laplacian\n"
43 " genLaplacian( \"z:10:20\" ) generates a 2D complex double laplacian matrix of size 200.\n"
44 " genLaplacian( \"10:1:10:2.:0.5\" ) generates a 2D real double laplacian matrix of size 100 where M = 2. * D - 0.5 * A.\n"
45 " genLaplacian( \"s:10\" ) generates a 1D real single laplacian matrix of size 10.\n"
106 long tmp1, tmp2, tmp3, tmp4;
114 size_t nfilename = strlen( filename );
116 tmpf = calloc(
spm_imax( nfilename, 256 ),
sizeof(
char) );
118 if ( sscanf( filename,
"%c:%255s", &flt, tmpf ) == 2 ) {
177 *dim1 = *dim2 = *dim3 = 1;
179 if ( sscanf( filename,
"%ld:%ld:%ld:%lf:%lf:%ld",
180 &tmp1, &tmp2, &tmp3, &val1, &val2, &tmp4 ) == 6 ) {
188 else if ( sscanf( filename,
"%ld:%ld:%ld:%lf:%lf", &tmp1, &tmp2, &tmp3, &val1, &val2 ) == 5 ) {
195 else if ( sscanf( filename,
"%ld:%ld:%ld:%lf", &tmp1, &tmp2, &tmp3, &val1 ) == 4 ) {
201 else if ( sscanf( filename,
"%ld:%ld:%ld", &tmp1, &tmp2, &tmp3 ) == 3 ) {
206 else if ( sscanf( filename,
"%ld:%ld", &tmp1, &tmp2 ) == 2 ) {
210 else if ( sscanf( filename,
"%ld", &tmp1 ) == 1 ) {
221 if ( (*dim1 == 0) || (*dim2 == 0) || (*dim3 == 0) ) {
306 spm->
gN = dim1 * dim2 * dim3;
324 fprintf( stderr,
"Issue while extending the matrix to multi-dof\n" );
382 spm->
gN = dim1 * dim2 * dim3;
400 fprintf( stderr,
"Issue while extending the matrix to multi-dof\n" );
void c_spmLaplacian_7points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate a laplacian matrix for a 3D 7-points stencil.
void c_spmLaplacian_27points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate an extended laplacian matrix for a 3D 27-points stencil.
void d_spmLaplacian_27points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate an extended laplacian matrix for a 3D 27-points stencil.
void d_spmLaplacian_7points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate a laplacian matrix for a 3D 7-points stencil.
double spm_fixdbl_t
Double datatype that is not converted through precision generator functions.
static spm_int_t spm_imax(spm_int_t a, spm_int_t b)
Internal function to compute max(a,b)
enum spm_coeftype_e spm_coeftype_t
Arithmetic types.
int spmParseLaplacianInfo(const char *filename, spm_coeftype_t *flttype, spm_int_t *dim1, spm_int_t *dim2, spm_int_t *dim3, double *alpha, double *beta, spm_int_t *dof)
Parse information given through the filename string to configure the laplacian matrix to generate.
void spmExit(spmatrix_t *spm)
Cleanup the spm structure but do not free the spm pointer.
void spmUpdateComputedFields(spmatrix_t *spm)
Update all the computed fields based on the static values stored.
int spm_int_t
The main integer datatype used in spm arrays.
int spmDofExtend(const spmatrix_t *spm, int type, int dof, spmatrix_t *spm_out)
Generate a random multidof spm from a given spm (with dof=1).
The sparse matrix data structure.
int genExtendedLaplacian(const char *filename, spmatrix_t *spm)
Generate a extended Laplacian of size spm->n.
static void(* laplacian_7points[6])(spmatrix_t *, spm_int_t, spm_int_t, spm_int_t, spm_fixdbl_t, spm_fixdbl_t)
Pointers to the 7 points Laplacian generator functions.
static void(* laplacian_27points[6])(spmatrix_t *, spm_int_t, spm_int_t, spm_int_t, spm_fixdbl_t, spm_fixdbl_t)
Pointers to the 27 points Laplacian generator functions.
int genLaplacian(const char *filename, spmatrix_t *spm)
Generate a Laplacian of size spm->n.
static void laplacian_usage(void)
Print the usage information to generate correct Laplacian matrices.
void p_spmLaplacian_7points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate a laplacian matrix for a 3D 7-points stencil.
void p_spmLaplacian_27points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate an extended laplacian matrix for a 3D 27-points stencil.
void s_spmLaplacian_7points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate a laplacian matrix for a 3D 7-points stencil.
void s_spmLaplacian_27points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate an extended laplacian matrix for a 3D 27-points stencil.
void z_spmLaplacian_7points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate a laplacian matrix for a 3D 7-points stencil.
void z_spmLaplacian_27points(spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta)
Generate an extended laplacian matrix for a 3D 27-points stencil.