Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
spm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
spm
Commits
5c06e1e3
Commit
5c06e1e3
authored
7 years ago
by
Mathieu Faverge
Browse files
Options
Downloads
Patches
Plain Diff
Remove 1D and 2 laplacian generator to make a single one, and add the alpha/beta parameters
parent
5bf3f770
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
drivers/laplacian.c
+73
-53
73 additions, 53 deletions
drivers/laplacian.c
drivers/laplacian.h
+5
-17
5 additions, 17 deletions
drivers/laplacian.h
z_spm_laplacian.c
+62
-245
62 additions, 245 deletions
z_spm_laplacian.c
with
140 additions
and
315 deletions
drivers/laplacian.c
+
73
−
53
View file @
5c06e1e3
...
...
@@ -33,17 +33,21 @@ static inline void
laplacian_usage
(
void
)
{
fprintf
(
stderr
,
"Usage: genLaplacian(
\"
[<type>:]<dim1>[:<dim2>[:<dim3>]]
\"
)
\n
"
"Usage: genLaplacian(
\"
[<type>:]<dim1>[:<dim2>[:<dim3>[:<alpha>[:<beta>]]]]
\"
)
\n
"
" Generate a Laplacian matrix M, of the form alpha * D - beta * A,
\n
"
" where D is the degree matrix, and A the adjacency matrix.
\n
"
" <type> p = pattern only
\n
"
" s = real simple
\n
"
" d = real double [default]
\n
"
" c = complex simple
\n
"
" z = complex double
\n
"
" <dim1> size of the first dimension of the
1D|2D|3D
laplacian
\n
"
" <dim2> size of the second dimension of the
2D|3D
laplacian
\n
"
" <dim3> size of the third dimension of the
3D
laplacian
\n
"
" <dim1> size of the first dimension of the laplacian
\n
"
" <dim2> size of the second dimension of the laplacian
\n
"
" <dim3> size of the third dimension of the laplacian
\n
"
" Example:
\n
"
" genLaplacian(
\"
z:10:20
\"
) generates a 2D complex laplacian matrix of size 200.
\n
"
" genLaplacian(
\"
z:10:20
\"
) generates a 2D complex double laplacian matrix of size 200.
\n
"
" 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
"
" genLaplacian(
\"
s:10
\"
) generates a 1D real single laplacian matrix of size 10.
\n
"
);
}
...
...
@@ -52,8 +56,13 @@ laplacian_usage(void)
*
* @ingroup pastix_spm_driver
*
* laplacian_parse_info - Parse information given through the filename string to
* configure the laplacian matrix to generate.
* @brief Parse information given through the filename string to configure the
* laplacian matrix to generate.
*
* The laplacian will be of size dim1 * dim2 * dim3, and will be equal to
* \[ M = \alpha * D - \beta * A \]
*
* where D is the degree matrix, and A the adjacency matrix.
*
*******************************************************************************
*
...
...
@@ -67,11 +76,25 @@ laplacian_usage(void)
* At exit, the fields of the spm are initialized and especially the
* type, symmetry and number of unknows are setup.
*
* @param[out] dim1
* The first dimension of the laplacian
*
* @param[out] dim2
* The second dimension of the laplacian
*
* @param[out] dim3
* The third dimension of the laplacian
*
* @param[out] alpha
* The alpha coefficient for the degree matrix
*
* @param[out] beta
* The beta coefficient for the adjacency matrix
*
*******************************************************************************
*
* @return
* \retval PASTIX_SUCCESS if the matrix has been generated successfully
* \retval PASTIX_ERR_BADPARAMETER if the configuration string is incorrect
* @retval PASTIX_SUCCESS if the matrix has been generated successfully
* @retval PASTIX_ERR_BADPARAMETER if the configuration string is incorrect
*
*******************************************************************************/
static
inline
int
...
...
@@ -79,14 +102,20 @@ laplacian_parse_info( const char *filename,
pastix_spm_t
*
spm
,
pastix_int_t
*
dim1
,
pastix_int_t
*
dim2
,
pastix_int_t
*
dim3
)
pastix_int_t
*
dim3
,
double
*
alpha
,
double
*
beta
)
{
double
val1
,
val2
;
long
tmp1
,
tmp2
,
tmp3
;
spm
->
colptr
=
NULL
;
spm
->
rowptr
=
NULL
;
spm
->
values
=
NULL
;
spm
->
loc2glob
=
NULL
;
*
alpha
=
1
.;
*
beta
=
1
.;
/* Look for the datatype */
{
char
flt
;
...
...
@@ -152,7 +181,22 @@ laplacian_parse_info( const char *filename,
/* Scan the dimensions */
*
dim1
=
*
dim2
=
*
dim3
=
0
;
if
(
sscanf
(
filename
,
"%ld:%ld:%ld"
,
&
tmp1
,
&
tmp2
,
&
tmp3
)
==
3
)
{
if
(
sscanf
(
filename
,
"%ld:%ld:%ld:%lf:%lf"
,
&
tmp1
,
&
tmp2
,
&
tmp3
,
&
val1
,
&
val2
)
==
5
)
{
*
dim1
=
(
pastix_int_t
)
tmp1
;
*
dim2
=
(
pastix_int_t
)
tmp2
;
*
dim3
=
(
pastix_int_t
)
tmp3
;
*
alpha
=
val1
;
*
beta
=
val2
;
spm
->
gN
=
(
*
dim1
)
*
(
*
dim2
)
*
(
*
dim3
);
}
else
if
(
sscanf
(
filename
,
"%ld:%ld:%ld:%lf"
,
&
tmp1
,
&
tmp2
,
&
tmp3
,
&
val1
)
==
4
)
{
*
dim1
=
(
pastix_int_t
)
tmp1
;
*
dim2
=
(
pastix_int_t
)
tmp2
;
*
dim3
=
(
pastix_int_t
)
tmp3
;
*
alpha
=
val1
;
spm
->
gN
=
(
*
dim1
)
*
(
*
dim2
)
*
(
*
dim3
);
}
else
if
(
sscanf
(
filename
,
"%ld:%ld:%ld"
,
&
tmp1
,
&
tmp2
,
&
tmp3
)
==
3
)
{
*
dim1
=
(
pastix_int_t
)
tmp1
;
*
dim2
=
(
pastix_int_t
)
tmp2
;
*
dim3
=
(
pastix_int_t
)
tmp3
;
...
...
@@ -178,43 +222,26 @@ laplacian_parse_info( const char *filename,
return
PASTIX_ERR_BADPARAMETER
;
}
fprintf
(
stderr
,
"x=%ld, y=%ld, z=%ld, alpha=%lf, beta=%lf
\n
"
,
*
dim1
,
*
dim2
,
*
dim3
,
*
alpha
,
*
beta
);
spm
->
n
=
spm
->
gN
;
return
PASTIX_SUCCESS
;
}
static
void
(
*
laplacian_table1D
[
6
])(
pastix_spm_t
*
,
pastix_int_t
)
=
{
p_spmLaplacian1D
,
NULL
,
s_spmLaplacian1D
,
d_spmLaplacian1D
,
c_spmLaplacian1D
,
z_spmLaplacian1D
};
static
void
(
*
laplacian_table2D
[
6
])(
pastix_spm_t
*
,
pastix_int_t
,
pastix_int_t
)
=
static
void
(
*
laplacian_7points
[
6
])(
pastix_spm_t
*
,
pastix_int_t
,
pastix_int_t
,
pastix_int_t
,
pastix_fixdbl_t
,
pastix_fixdbl_t
)
=
{
p_spmLaplacian
2D
,
p_spmLaplacian
_7points
,
NULL
,
s_spmLaplacian2D
,
d_spmLaplacian2D
,
c_spmLaplacian2D
,
z_spmLaplacian2D
};
static
void
(
*
laplacian_table3D
[
6
])(
pastix_spm_t
*
,
pastix_int_t
,
pastix_int_t
,
pastix_int_t
)
=
{
p_spmLaplacian3D
,
NULL
,
s_spmLaplacian3D
,
d_spmLaplacian3D
,
c_spmLaplacian3D
,
z_spmLaplacian3D
s_spmLaplacian_7points
,
d_spmLaplacian_7points
,
c_spmLaplacian_7points
,
z_spmLaplacian_7points
};
static
void
(
*
extended_laplacian_table2D
[
6
])(
pastix_spm_t
*
,
pastix_int_t
,
pastix_int_t
)
=
{
p_spmLaplacian2D
,
p_spm
Extended
Laplacian2D
,
NULL
,
s_spmExtendedLaplacian2D
,
d_spmExtendedLaplacian2D
,
...
...
@@ -269,21 +296,15 @@ genLaplacian( const char *filename,
pastix_spm_t
*
spm
)
{
pastix_int_t
dim1
,
dim2
,
dim3
;
double
alpha
=
1
.;
double
beta
=
1
.;
int
rc
;
rc
=
laplacian_parse_info
(
filename
,
spm
,
&
dim1
,
&
dim2
,
&
dim3
);
rc
=
laplacian_parse_info
(
filename
,
spm
,
&
dim1
,
&
dim2
,
&
dim3
,
&
alpha
,
&
beta
);
if
(
rc
!=
PASTIX_SUCCESS
)
return
rc
;
if
(
dim3
>
0
)
{
laplacian_table3D
[
spm
->
flttype
](
spm
,
dim1
,
dim2
,
dim3
);
}
else
if
(
dim2
>
0
)
{
laplacian_table2D
[
spm
->
flttype
](
spm
,
dim1
,
dim2
);
}
else
{
laplacian_table1D
[
spm
->
flttype
](
spm
,
dim1
);
}
laplacian_7points
[
spm
->
flttype
](
spm
,
dim1
,
dim2
,
dim3
,
alpha
,
beta
);
return
PASTIX_SUCCESS
;
}
...
...
@@ -325,9 +346,11 @@ genExtendedLaplacian( const char *filename,
pastix_spm_t
*
spm
)
{
pastix_int_t
dim1
,
dim2
,
dim3
;
double
alpha
=
1
.;
double
beta
=
1
.;
int
rc
;
rc
=
laplacian_parse_info
(
filename
,
spm
,
&
dim1
,
&
dim2
,
&
dim3
);
rc
=
laplacian_parse_info
(
filename
,
spm
,
&
dim1
,
&
dim2
,
&
dim3
,
&
alpha
,
&
beta
);
if
(
rc
!=
PASTIX_SUCCESS
)
return
rc
;
...
...
@@ -337,9 +360,6 @@ genExtendedLaplacian( const char *filename,
else
if
(
dim2
>
0
)
{
extended_laplacian_table2D
[
spm
->
flttype
](
spm
,
dim1
,
dim2
);
}
else
{
laplacian_table1D
[
spm
->
flttype
](
spm
,
dim1
);
}
return
PASTIX_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
drivers/laplacian.h
+
5
−
17
View file @
5c06e1e3
...
...
@@ -12,23 +12,11 @@
#ifndef _LAPLACIAN_H_
#define _LAPLACIAN_H_
void
z_spmLaplacian1D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
);
void
c_spmLaplacian1D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
);
void
d_spmLaplacian1D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
);
void
s_spmLaplacian1D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
);
void
p_spmLaplacian1D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
);
void
z_spmLaplacian2D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
);
void
c_spmLaplacian2D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
);
void
d_spmLaplacian2D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
);
void
s_spmLaplacian2D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
);
void
p_spmLaplacian2D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
);
void
z_spmLaplacian3D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
);
void
c_spmLaplacian3D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
);
void
d_spmLaplacian3D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
);
void
s_spmLaplacian3D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
);
void
p_spmLaplacian3D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
);
void
z_spmLaplacian_7points
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
,
pastix_fixdbl_t
alpha
,
pastix_fixdbl_t
beta
);
void
c_spmLaplacian_7points
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
,
pastix_fixdbl_t
alpha
,
pastix_fixdbl_t
beta
);
void
d_spmLaplacian_7points
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
,
pastix_fixdbl_t
alpha
,
pastix_fixdbl_t
beta
);
void
s_spmLaplacian_7points
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
,
pastix_fixdbl_t
alpha
,
pastix_fixdbl_t
beta
);
void
p_spmLaplacian_7points
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
,
pastix_fixdbl_t
alpha
,
pastix_fixdbl_t
beta
);
void
z_spmExtendedLaplacian2D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
);
void
c_spmExtendedLaplacian2D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
);
...
...
This diff is collapsed.
Click to expand it.
z_spm_laplacian.c
+
62
−
245
View file @
5c06e1e3
...
...
@@ -24,207 +24,8 @@
*
* @ingroup spm_dev_driver
*
* z_spmLaplacian1D - Generate a 1D laplacian matrix.
*
* Example:
* > 1 -1 0 0
* > -1 2 -1 0
* > 0 -1 2 -1
* > 0 0 -1 1
*
*******************************************************************************
*
* @param[inout] spm
* At start, an allocated spm structure.
* Contains the size of the laplacian in spm->n.
* At exit, contains the matrix in csc format.
*
* @param[in] dim1
* contains the dimension of the 1D laplacian.
*
*******************************************************************************/
void
z_spmLaplacian1D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
)
{
pastix_complex64_t
*
valptr
;
pastix_int_t
*
colptr
,
*
rowptr
;
pastix_int_t
i
,
j
;
pastix_int_t
nnz
=
2
*
(
spm
->
gN
)
-
1
;
spm
->
mtxtype
=
PastixSymmetric
;
spm
->
flttype
=
PastixComplex64
;
spm
->
fmttype
=
PastixCSC
;
spm
->
gnnz
=
nnz
;
spm
->
nnz
=
nnz
;
spm
->
dof
=
1
;
assert
(
spm
->
gN
==
dim1
);
/* Allocating */
spm
->
colptr
=
malloc
((
spm
->
n
+
1
)
*
sizeof
(
pastix_int_t
));
spm
->
rowptr
=
malloc
(
nnz
*
sizeof
(
pastix_int_t
));
assert
(
spm
->
colptr
);
assert
(
spm
->
rowptr
);
#if !defined(PRECISION_p)
spm
->
values
=
malloc
(
nnz
*
sizeof
(
pastix_complex64_t
));
assert
(
spm
->
values
);
#endif
/* Building ia, ja and values*/
colptr
=
spm
->
colptr
;
rowptr
=
spm
->
rowptr
;
valptr
=
(
pastix_complex64_t
*
)(
spm
->
values
);
j
=
0
;
*
colptr
=
1
;
colptr
++
;
/* baseval */
for
(
i
=
0
;
i
<
dim1
;
i
++
,
colptr
++
)
{
*
rowptr
=
i
+
1
;
#if !defined(PRECISION_p)
if
(
(
i
==
0
)
||
(
i
==
dim1
-
1
)
)
{
*
valptr
=
(
pastix_complex64_t
)
1
.;
}
else
{
*
valptr
=
(
pastix_complex64_t
)
2
.;
}
#endif
j
++
;
valptr
++
;
rowptr
++
;
if
(
i
<
spm
->
gN
-
1
)
{
*
rowptr
=
i
+
2
;
#if defined(PRECISION_z) || defined(PRECISION_c)
*
valptr
=
-
1
.
+
2
.
*
_Complex_I
;
#elif defined(PRECISION_d) || defined(PRECISION_s)
*
valptr
=
-
1
.;
#endif
j
++
;
rowptr
++
;
valptr
++
;
}
*
colptr
=
j
+
1
;
}
assert
(
(
spm
->
colptr
[
dim1
]
-
spm
->
colptr
[
0
])
==
nnz
);
}
/**
*******************************************************************************
*
* @ingroup spm_dev_driver
*
* z_spmLaplacian2D - Generate a 2D laplacian matrix.
*
* Example:
* > 2 -1 0 -1 0 0
* > -1 3 -1 0 -1 0
* > 0 -1 2 0 0 -1
* > -1 0 0 2 -1 0
* > 0 -1 0 -1 3 -1
* > 0 0 -1 0 -1 2
*
*******************************************************************************
*
* @param[inout] spm
* At start, an allocated spm structure.
* Contains the size of the laplacian in spm->n.
* At exit, contains the matrix in csc format.
*
* @param[in] dim1
* contains the first dimension of the 2D grid of the laplacian.
*
* @param[in] dim2
* contains the second dimension of the 2D grid of the laplacian.
*
*******************************************************************************/
void
z_spmLaplacian2D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
)
{
pastix_complex64_t
*
valptr
;
pastix_int_t
*
colptr
,
*
rowptr
;
pastix_int_t
i
,
j
,
k
;
pastix_int_t
nnz
=
(
2
*
(
dim1
)
-
1
)
*
dim2
+
(
dim2
-
1
)
*
dim1
;
spm
->
mtxtype
=
PastixHermitian
;
spm
->
flttype
=
PastixComplex64
;
spm
->
fmttype
=
PastixCSC
;
spm
->
gnnz
=
nnz
;
spm
->
nnz
=
nnz
;
spm
->
dof
=
1
;
assert
(
spm
->
gN
==
dim1
*
dim2
);
/* Allocating */
spm
->
colptr
=
malloc
((
spm
->
n
+
1
)
*
sizeof
(
pastix_int_t
));
spm
->
rowptr
=
malloc
(
nnz
*
sizeof
(
pastix_int_t
));
assert
(
spm
->
colptr
);
assert
(
spm
->
rowptr
);
#if !defined(PRECISION_p)
spm
->
values
=
malloc
(
nnz
*
sizeof
(
pastix_complex64_t
));
assert
(
spm
->
values
);
#endif
/* Building ia, ja and values*/
colptr
=
spm
->
colptr
;
rowptr
=
spm
->
rowptr
;
valptr
=
(
pastix_complex64_t
*
)(
spm
->
values
);
/* Building ia, ja and values*/
*
colptr
=
1
;
k
=
1
;
/* Column index in the matrix ((i-1) * dim1 + j-1) */
for
(
i
=
1
;
i
<=
dim2
;
i
++
)
{
for
(
j
=
1
;
j
<=
dim1
;
j
++
)
{
colptr
[
1
]
=
colptr
[
0
];
/* Diagonal value */
*
rowptr
=
k
;
#if !defined(PRECISION_p)
*
valptr
=
(
pastix_complex64_t
)
4
.;
if
(
j
==
dim1
||
j
==
1
)
*
valptr
-=
(
pastix_complex64_t
)
1
.;
if
(
i
==
dim2
||
i
==
1
)
*
valptr
-=
(
pastix_complex64_t
)
1
.;
#endif
valptr
++
;
rowptr
++
;
colptr
[
1
]
++
;
/* Connexion along dimension 1 */
if
(
j
<
dim1
)
{
*
rowptr
=
k
+
1
;
#if !defined(PRECISION_p)
*
valptr
=
(
pastix_complex64_t
)
-
1
.;
#endif
valptr
++
;
rowptr
++
;
colptr
[
1
]
++
;
}
/* Connexion along dimension 2 */
if
(
i
<
dim2
)
{
*
rowptr
=
k
+
dim1
;
#if !defined(PRECISION_p)
*
valptr
=
(
pastix_complex64_t
)
-
1
.;
#endif
valptr
++
;
rowptr
++
;
colptr
[
1
]
++
;
}
colptr
++
;
k
++
;
}
}
assert
(
(
spm
->
colptr
[
spm
->
gN
]
-
spm
->
colptr
[
0
])
==
nnz
);
}
/**
*******************************************************************************
*
* @ingroup spm_dev_driver
*
* z_spmLaplacian3D - Generate a 3D laplacian matrix.
* @brief Generate a laplacian matrix for a 7-points stencil
* \[ M = \alpha * D - \beta * A \]
*
* Example:
* > 3 -1 -1 0 -1 0 0 0
...
...
@@ -244,20 +45,28 @@ z_spmLaplacian2D( pastix_spm_t *spm,
* At exit, contains the matrix in csc format.
*
* @param[in] dim1
* contains the first dimension of the
3D
grid of the laplacian.
* contains the first dimension of the grid of the laplacian.
*
* @param[in] dim2
* contains the second dimension of the
3D
grid of the laplacian.
* contains the second dimension of the grid of the laplacian.
*
* @param[in] dim3
* contains the third dimension of the 3D grid of the laplacian.
* contains the third dimension of the grid of the laplacian.
*
* @param[in] alpha
* The alpha coefficient for the degree matrix
*
* @param[in] beta
* The beta coefficient for the adjacency matrix
*
*******************************************************************************/
void
z_spmLaplacian3D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
)
z_spmLaplacian_7points
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
,
pastix_fixdbl_t
alpha
,
pastix_fixdbl_t
beta
)
{
pastix_complex64_t
*
valptr
;
...
...
@@ -299,19 +108,24 @@ z_spmLaplacian3D( pastix_spm_t *spm,
{
for
(
k
=
1
;
k
<=
dim1
;
k
++
)
{
colptr
[
1
]
=
colptr
[
0
];
/* Diagonal value */
*
rowptr
=
l
;
#if !defined(PRECISION_p)
*
valptr
=
(
pastix_complex64_t
)
6
.;
if
(
k
==
dim1
||
k
==
1
)
*
valptr
-=
(
pastix_complex64_t
)
1
.;
if
(
j
==
dim2
||
j
==
1
)
*
valptr
-=
(
pastix_complex64_t
)
1
.;
if
(
i
==
dim3
||
i
==
1
)
*
valptr
-=
(
pastix_complex64_t
)
1
.;
*
valptr
=
6
.
*
alpha
;
if
(
k
==
1
)
*
valptr
-=
alpha
;
if
(
k
==
dim1
)
*
valptr
-=
alpha
;
if
(
j
==
1
)
*
valptr
-=
alpha
;
if
(
j
==
dim2
)
*
valptr
-=
alpha
;
if
(
i
==
1
)
*
valptr
-=
alpha
;
if
(
i
==
dim3
)
*
valptr
-=
alpha
;
#endif
valptr
++
;
rowptr
++
;
colptr
[
1
]
++
;
...
...
@@ -319,7 +133,7 @@ z_spmLaplacian3D( pastix_spm_t *spm,
if
(
k
<
dim1
)
{
*
rowptr
=
l
+
1
;
#if !defined(PRECISION_p)
*
valptr
=
(
pastix_complex64_t
)
-
1
.
;
*
valptr
=
-
beta
;
#endif
valptr
++
;
rowptr
++
;
colptr
[
1
]
++
;
}
...
...
@@ -328,7 +142,7 @@ z_spmLaplacian3D( pastix_spm_t *spm,
if
(
j
<
dim2
)
{
*
rowptr
=
l
+
dim1
;
#if !defined(PRECISION_p)
*
valptr
=
(
pastix_complex64_t
)
-
1
.
;
*
valptr
=
-
beta
;
#endif
valptr
++
;
rowptr
++
;
colptr
[
1
]
++
;
}
...
...
@@ -337,7 +151,7 @@ z_spmLaplacian3D( pastix_spm_t *spm,
if
(
i
<
dim3
)
{
*
rowptr
=
l
+
dim1
*
dim2
;
#if !defined(PRECISION_p)
*
valptr
=
(
pastix_complex64_t
)
-
1
.
;
*
valptr
=
-
beta
;
#endif
valptr
++
;
rowptr
++
;
colptr
[
1
]
++
;
}
...
...
@@ -348,6 +162,7 @@ z_spmLaplacian3D( pastix_spm_t *spm,
}
assert
(
(
spm
->
colptr
[
spm
->
gN
]
-
spm
->
colptr
[
0
])
==
nnz
);
(
void
)
alpha
;
(
void
)
beta
;
}
/**
...
...
@@ -478,7 +293,8 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm,
*
* @ingroup spm_dev_driver
*
* z_spmExtendedLaplacian3D - Generate a 3D extended laplacian matrix.
* @brief Generate an extended laplacian matrix for a 27-points stencil with
* \[ M = \alpha * D - \beta * A \]
*
*******************************************************************************
*
...
...
@@ -488,26 +304,28 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm,
* At exit, contains the matrix in csc format.
*
* @param[in] dim1
* contains the first dimension of the
3D
grid of the laplacian.
* contains the first dimension of the grid of the laplacian.
*
* @param[in] dim2
* contains the second dimension of the
3D
grid of the laplacian.
* contains the second dimension of the grid of the laplacian.
*
* @param[in] dim3
* contains the
secon
d dimension of the
3D
grid of the laplacian.
* contains the
thir
d dimension of the grid of the laplacian.
*
*******************************************************************************/
void
z_spmExtendedLaplacian3D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
)
z_spmExtendedLaplacian3D
(
pastix_spm_t
*
spm
,
pastix_int_t
dim1
,
pastix_int_t
dim2
,
pastix_int_t
dim3
)
{
pastix_complex64_t
*
valptr
;
pastix_int_t
*
colptr
,
*
rowptr
;
pastix_int_t
i
,
j
,
k
,
l
;
pastix_int_t
nnz
=
(
2
*
dim1
-
1
)
*
dim2
*
dim3
+
(
3
*
dim1
-
2
)
*
(
dim2
-
1
)
*
dim3
+
((
3
*
dim1
-
2
)
*
dim2
+
2
*
(
3
*
dim1
-
2
)
*
(
dim2
-
1
))
*
(
dim3
-
1
);
pastix_int_t
nnz
=
(
2
*
dim1
-
1
)
*
dim2
*
dim3
+
(
3
*
dim1
-
2
)
*
(
dim2
-
1
)
*
dim3
+
((
3
*
dim1
-
2
)
*
dim2
+
2
*
(
3
*
dim1
-
2
)
*
(
dim2
-
1
))
*
(
dim3
-
1
);
spm
->
mtxtype
=
PastixSymmetric
;
spm
->
flttype
=
PastixComplex64
;
...
...
@@ -543,28 +361,27 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm,
{
for
(
k
=
1
;
k
<=
dim1
;
k
++
)
{
colptr
[
1
]
=
colptr
[
0
];
/* Diagonal value */
*
rowptr
=
l
;
#if !defined(PRECISION_p)
if
(
(
j
==
dim2
||
j
==
1
)
&&
(
i
==
dim3
||
i
==
1
)
&&
(
k
==
dim1
||
i
==
1
)
)
*
valptr
=
(
pastix_complex64_t
)
4
.
75
;
else
if
(
(
j
!=
dim2
||
j
!=
1
)
&&
(
i
==
dim3
||
i
==
1
)
&&
(
k
==
dim1
||
i
==
1
)
)
*
valptr
=
(
pastix_complex64_t
)
10
.;
else
if
(
(
j
==
dim2
||
j
==
1
)
&&
(
i
!=
dim3
||
i
!=
1
)
&&
(
k
==
dim1
||
i
==
1
)
)
*
valptr
=
(
pastix_complex64_t
)
10
.;
else
if
(
(
j
==
dim2
||
j
==
1
)
&&
(
i
==
dim3
||
i
==
1
)
&&
(
k
!=
dim1
||
i
!=
1
)
)
*
valptr
=
(
pastix_complex64_t
)
10
.;
else
if
(
(
j
!=
dim2
||
j
!=
1
)
&&
(
i
!=
dim3
||
i
!=
1
)
&&
(
k
==
dim1
||
i
==
1
)
)
*
valptr
=
(
pastix_complex64_t
)
7
.;
else
if
(
(
j
==
dim2
||
j
==
1
)
&&
(
i
!=
dim3
||
i
!=
1
)
&&
(
k
!=
dim1
||
i
!=
1
)
)
*
valptr
=
(
pastix_complex64_t
)
7
.;
else
if
(
(
j
!=
dim2
||
j
!=
1
)
&&
(
i
==
dim3
||
i
==
1
)
&&
(
k
!=
dim1
||
i
!=
1
)
)
*
valptr
=
(
pastix_complex64_t
)
7
.;
else
*
valptr
=
(
pastix_complex64_t
)
14
.;
if
(
(
j
==
dim2
||
j
==
1
)
&&
(
i
==
dim3
||
i
==
1
)
&&
(
k
==
dim1
||
i
==
1
)
)
*
valptr
=
(
pastix_complex64_t
)
4
.
75
;
else
if
(
(
j
!=
dim2
||
j
!=
1
)
&&
(
i
==
dim3
||
i
==
1
)
&&
(
k
==
dim1
||
i
==
1
)
)
*
valptr
=
(
pastix_complex64_t
)
10
.;
else
if
(
(
j
==
dim2
||
j
==
1
)
&&
(
i
!=
dim3
||
i
!=
1
)
&&
(
k
==
dim1
||
i
==
1
)
)
*
valptr
=
(
pastix_complex64_t
)
10
.;
else
if
(
(
j
==
dim2
||
j
==
1
)
&&
(
i
==
dim3
||
i
==
1
)
&&
(
k
!=
dim1
||
i
!=
1
)
)
*
valptr
=
(
pastix_complex64_t
)
10
.;
else
if
(
(
j
!=
dim2
||
j
!=
1
)
&&
(
i
!=
dim3
||
i
!=
1
)
&&
(
k
==
dim1
||
i
==
1
)
)
*
valptr
=
(
pastix_complex64_t
)
7
.;
else
if
(
(
j
==
dim2
||
j
==
1
)
&&
(
i
!=
dim3
||
i
!=
1
)
&&
(
k
!=
dim1
||
i
!=
1
)
)
*
valptr
=
(
pastix_complex64_t
)
7
.;
else
if
(
(
j
!=
dim2
||
j
!=
1
)
&&
(
i
==
dim3
||
i
==
1
)
&&
(
k
!=
dim1
||
i
!=
1
)
)
*
valptr
=
(
pastix_complex64_t
)
7
.;
else
*
valptr
=
(
pastix_complex64_t
)
14
.;
#endif
valptr
++
;
rowptr
++
;
colptr
[
1
]
++
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment