Macaulay2 Engine
Loading...
Searching...
No Matches
◆
computeLU()
[2/5]
void
DMatLUinPlace
<
M2::ARingRR
>::computeLU
(
)
inline
private
Definition at line
319
of file
dmat-lu-inplace.hpp
.
320
{
321
if
(
mIsDone
)
return
;
322
323
// std::cout << "computing LU decomposition ARingRR" << std::endl;
324
int
rows
=
static_cast<
int
>
(
mLU
.numRows());
325
int
cols
=
static_cast<
int
>
(
mLU
.numColumns());
326
int
info
;
327
int
min
= (
rows
<=
cols
) ?
rows
:
cols
;
328
329
if
(
min
== 0)
330
return
;
331
332
int
*
perm
=
new
int
[
min
];
333
std::vector<double>
copyA
=
make_lapack_array
(
mLU
);
334
335
dgetrf_
(&
rows
, &
cols
,
copyA
.data(), &
rows
,
perm
, &
info
);
336
337
if
(
info
< 0)
338
{
339
// First, clean up, then throw an exception
340
delete
[]
perm
;
341
throw
exc::engine_error
(
"argument passed to dgetrf had an illegal value"
);
342
}
343
344
// Now copy back to row major order
345
fill_from_lapack_array
(
copyA
,
mLU
);
346
347
// Now place the correct permutation into mPerm
348
for
(
int
i
= 0;
i
<
min
;
i
++)
349
{
350
int
thisloc
=
perm
[
i
] - 1;
351
if
(
i
!=
thisloc
)
352
{
353
mSign
=
not
mSign
;
354
size_t
tmp
=
mPerm
[
thisloc
];
355
mPerm
[
thisloc
] =
mPerm
[
i
];
356
mPerm
[
i
] =
tmp
;
357
}
358
}
359
360
LUUtil<RingType>::computePivotColumns
(
mLU
,
mPivotColumns
);
361
mIsDone
=
true
;
362
363
delete
[]
perm
;
364
}
DMatLUinPlace::mSign
bool mSign
Definition
dmat-lu-inplace.hpp:117
DMatLUinPlace::mLU
Mat mLU
Definition
dmat-lu-inplace.hpp:115
DMatLUinPlace::mPivotColumns
std::vector< size_t > mPivotColumns
Definition
dmat-lu-inplace.hpp:119
DMatLUinPlace::mPerm
std::vector< size_t > mPerm
Definition
dmat-lu-inplace.hpp:116
DMatLUinPlace::mIsDone
bool mIsDone
Definition
dmat-lu-inplace.hpp:118
DMatLUinPlace
Definition
dmat-lu-inplace.hpp:86
LUUtil::computePivotColumns
static void computePivotColumns(const Mat &LU, std::vector< size_t > &result_columns)
Definition
dmat-lu-inplace.hpp:440
make_lapack_array
std::vector< double > make_lapack_array(const DMatRR &mat)
Definition
lapack.cpp:20
fill_from_lapack_array
void fill_from_lapack_array(const std::vector< double > &doubles, DMatRR &mat)
Definition
lapack.cpp:45
dgetrf_
void dgetrf_(const int *rows, const int *cols, double *A, const int *ld, int *ipiv, int *info)
DMatLUinPlace
Generated on
for Macaulay2 Engine by
1.15.0