Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
69932a58
Commit
69932a58
authored
1 year ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Create a LAPACK interface library
parent
1aaea3d6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/lapack_calls.h
+20
-0
20 additions, 0 deletions
src/include/lapack_calls.h
src/libnptm/lapack_calls.cpp
+34
-0
34 additions, 0 deletions
src/libnptm/lapack_calls.cpp
with
54 additions
and
0 deletions
src/include/lapack_calls.h
0 → 100644
+
20
−
0
View file @
69932a58
/*! \file lapack_calss.h
*
* \brief C++ interface to LAPACK calls.
*
*/
#ifndef INCLUDE_LAPACK_CALLS_H_
#define INCLUDE_LAPACK_CALLS_H_
/*! \brief Invert a complex matrix with double precision elements.
*
* Use LAPACKE64 to perform an in-place matrix inversion for a complex
* matrix with double precision elements.
*
* \param mat: Matrix of complex. The matrix to be inverted.
* \param n: `int` The number of rows and columns of the [n x n] matrix.
*/
void
zinvert
(
std
::
complex
<
double
>
**
mat
,
int
n
);
#endif
This diff is collapsed.
Click to expand it.
src/libnptm/lapack_calls.cpp
0 → 100644
+
34
−
0
View file @
69932a58
#include
<complex>
#include
<cstdlib>
#include
"lapacke.h"
#ifndef INCLUDE_LAPACK_CALLS_H_
#define INCLUDE_LAPACK_CALLS_H_
#include
"../include/lapac_calls.h"
#endif
using
namespace
std
;
void
zinvert
(
std
::
complex
<
double
>
**
mat
,
int
n
){
__complex__
double
*
arr
=
new
__complex__
double
[
n
*
n
];
const
__complex__
double
uim
=
1.0
di
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
int
idx
=
i
*
n
+
j
;
arr
[
idx
]
=
mat
[
i
][
j
].
real
()
+
uim
*
mat
[
i
][
j
].
imag
();
}
}
int
*
IPIV
=
new
int
[
n
];
LAPACKE_zgetrf
(
LAPACK_ROW_MAJOR
,
N
,
N
,
arr
,
N
,
IPIV
);
LAPACKE_zgetri
(
LAPACK_ROW_MAJOR
,
N
,
arr
,
N
,
IPIV
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
int
idx
=
i
*
n
+
j
;
mat
[
i
][
j
]
=
complex
<
double
>
(
__real__
arr
[
idx
],
__imag__
arr
[
idx
]);
}
}
delete
[]
IPIV
;
delete
[]
arr
;
}
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