FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire/src/api/cpp/lapack.cpp at master · arrayfire/arrayfire · GitHub
arrayfire
arrayfire
Repository navigation
Code
Issues
292
(292)
Pull requests
39
(39)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
arrayfire
/
src
/
api
/
cpp
/
lapack.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
150 lines (130 loc) · 4.21 KB
Breadcrumbs
arrayfire
/
src
/
api
/
cpp
/
lapack.cpp
Copy path
File metadata and controls
150 lines (130 loc) · 4.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
*******************************************************
*/
#
include
<
af/array.h
>
#
include
<
af/lapack.h
>
#
include
"
error.hpp
"
namespace
af
{
void
svd
(array &u, array &s, array &vt,
const
array &in) {
af_array sl =
0
, ul =
0
, vtl =
0
;
AF_THROW
(
af_svd
(&ul, &sl, &vtl, in.
get
()));
s =
array
(sl);
u =
array
(ul);
vt =
array
(vtl);
}
void
svdInPlace
(array &u, array &s, array &vt, array &in) {
af_array sl =
0
, ul =
0
, vtl =
0
;
AF_THROW
(
af_svd_inplace
(&ul, &sl, &vtl, in.
get
()));
s =
array
(sl);
u =
array
(ul);
vt =
array
(vtl);
}
void
lu
(array &out, array &pivot,
const
array &in,
const
bool
is_lapack_piv) {
out = in.
copy
();
af_array p =
0
;
AF_THROW
(
af_lu_inplace
(&p, out.
get
(), is_lapack_piv));
pivot =
array
(p);
}
void
lu
(array &lower, array &upper, array &pivot,
const
array &in) {
af_array l =
0
, u =
0
, p =
0
;
AF_THROW
(
af_lu
(&l, &u, &p, in.
get
()));
lower =
array
(l);
upper =
array
(u);
pivot =
array
(p);
}
void
luInPlace
(array &pivot, array &in,
const
bool
is_lapack_piv) {
af_array p =
0
;
AF_THROW
(
af_lu_inplace
(&p, in.
get
(), is_lapack_piv));
pivot =
array
(p);
}
void
qr
(array &out, array &tau,
const
array &in) {
out = in.
copy
();
af_array t =
0
;
AF_THROW
(
af_qr_inplace
(&t, out.
get
()));
tau =
array
(t);
}
void
qr
(array &q, array &r, array &tau,
const
array &in) {
af_array q_ =
0
, r_ =
0
, t_ =
0
;
AF_THROW
(
af_qr
(&q_, &r_, &t_, in.
get
()));
q =
array
(q_);
r =
array
(r_);
tau =
array
(t_);
}
void
qrInPlace
(array &tau, array &in) {
af_array t =
0
;
AF_THROW
(
af_qr_inplace
(&t, in.
get
()));
tau =
array
(t);
}
int
cholesky
(array &out,
const
array &in,
const
bool
is_upper) {
int
info =
0
;
af_array res;
AF_THROW
(
af_cholesky
(&res, &info, in.
get
(), is_upper));
out =
array
(res);
return
info;
}
int
choleskyInPlace
(array &in,
const
bool
is_upper) {
int
info =
0
;
AF_THROW
(
af_cholesky_inplace
(&info, in.
get
(), is_upper));
return
info;
}
array
solve
(
const
array &a,
const
array &b,
const
matProp options) {
af_array out;
AF_THROW
(
af_solve
(&out, a.
get
(), b.
get
(), options));
return
array
(out);
}
array
solveLU
(
const
array &a,
const
array &piv,
const
array &b,
const
matProp options) {
af_array out;
AF_THROW
(
af_solve_lu
(&out, a.
get
(), piv.
get
(), b.
get
(), options));
return
array
(out);
}
array
inverse
(
const
array &in,
const
matProp options) {
af_array out;
AF_THROW
(
af_inverse
(&out, in.
get
(), options));
return
array
(out);
}
array
pinverse
(
const
array &in,
const
double
tol,
const
matProp options) {
af_array out;
AF_THROW
(
af_pinverse
(&out, in.
get
(), tol, options));
return
array
(out);
}
unsigned
rank
(
const
array &in,
const
double
tol) {
unsigned
r =
0
;
AF_THROW
(
af_rank
(&r, in.
get
(), tol));
return
r;
}
#
define
INSTANTIATE_DET
(
TR, TC
) \
template
<> \
AFAPI
TR
det
(
const
array &in) { \
double
real; \
double
imag; \
AF_THROW
(
af_det
(&real, &imag, in.
get
())); \
return
real; \
} \
template
<> \
AFAPI
TC
det
(
const
array &in) { \
double
real; \
double
imag; \
AF_THROW
(
af_det
(&real, &imag, in.
get
())); \
TC
out
((
TR
)real, (
TR
)imag); \
return
out; \
}
INSTANTIATE_DET
(
float
, af_cfloat)
INSTANTIATE_DET
(
double
, af_cdouble)
double
norm
(
const
array &in,
const
normType type,
const
double
p,
const
double
q) {
double
out;
AF_THROW
(
af_norm
(&out, in.
get
(), type, p, q));
return
out;
}
bool
isLAPACKAvailable
() {
bool
out =
false
;
AF_THROW
(
af_is_lapack_available
(&out));
return
out;
}
}
//
namespace af
Back
|
FazBrowse Home
|
New Git URL