15 #if defined (CVM_STD_MUTEX)
22 char Chars::mchars[15] = {
'T',
'N',
'U',
'L',
'P',
'Q',
'B',
'E',
'R',
'A',
'S',
'V',
'O',
'I',
'C' };
32 CVM_API ErrMessages::ErrMessages()
33 : msUnknown(
"Unknown exception"), mmMsg()
35 #if defined (CVM_STD_MUTEX)
36 std::unique_lock<std::mutex> l(cvm_mutex);
41 mmMsg.insert(pair_Msg(
CVM_OK,
"All OK"));
42 mmMsg.insert(pair_Msg(
CVM_OUTOFMEMORY,
"Failed to allocate %u bytes of memory"));
45 mmMsg.insert(pair_Msg(
CVM_WRONGMKLARG,
"Wrong argument " CVM_TINT_FORMAT
" passed to BLAS or LAPACK subroutine"));
46 mmMsg.insert(pair_Msg(
CVM_WRONGMKLARG2,
"Wrong argument " CVM_TINT_FORMAT
" passed to BLAS or LAPACK subroutine %s"));
47 mmMsg.insert(pair_Msg(
CVM_SINGULARMATRIX,
"The diagonal element (or main minor) " CVM_TINT_FORMAT
" of the matrix is zero (or singular)"));
48 mmMsg.insert(pair_Msg(
CVM_NOTPOSITIVEDEFINITE,
"The leading minor of order " CVM_TINT_FORMAT
" (hence the matrix itself) is not positive-definite"));
49 mmMsg.insert(pair_Msg(
CVM_WRONGCHOLESKYFACTOR,
"The diagonal element " CVM_TINT_FORMAT
" of the Cholesky factor (hence the factor itself) is zero"));
50 mmMsg.insert(pair_Msg(
CVM_WRONGBUNCHKAUFMANFACTOR,
"The diagonal element " CVM_TINT_FORMAT
" of the Bunch-Kaufman factor (and hence the factor itself) is zero"));
51 mmMsg.insert(pair_Msg(
CVM_NOTPOSITIVEDIAG,
"The diagonal element " CVM_TINT_FORMAT
" of the matrix is nonpositive. Equilibration failed"));
54 #if defined (WIN32) || defined (_WIN32)
60 mmMsg.insert(pair_Msg(
CVM_SUBMATRIXACCESSERROR,
"Attempt to access non-continuous submatrix as a continuous array, see programmer\'s reference for details"));
61 mmMsg.insert(pair_Msg(
CVM_SUBMATRIXNOTAVAILABLE,
"Submatrix instantiation is not available for class \'%s\', see programmer\'s reference for details"));
63 mmMsg.insert(pair_Msg(
CVM_MATRIXNOTHERMITIAN,
"The matrix passed doesn't appear to be hermitian (%g vs. tolerance %g)"));
64 mmMsg.insert(pair_Msg(
CVM_BREAKS_HERMITIANITY,
"This operation could make the matrix non-hermitian. Use %s instead"));
65 mmMsg.insert(pair_Msg(
CVM_METHODNOTAVAILABLE,
"Function \'%s\' is not available for class \'%s\'. See programmer\'s reference for details"));
68 mmMsg.insert(pair_Msg(
CVM_NOT_CONJUGATED,
"Complex numbers are not conjugated: (%g,%g) vs. (%g,%g) with tolerance %g"));
70 mmMsg.insert(pair_Msg(
CVM_WRONGSIZE_LT,
"Wrong size: " CVM_TINT_FORMAT
" < " CVM_TINT_FORMAT));
71 mmMsg.insert(pair_Msg(
CVM_WRONGSIZE_LE,
"Wrong size: " CVM_TINT_FORMAT
" <= " CVM_TINT_FORMAT));
72 mmMsg.insert(pair_Msg(
CVM_INDEX_GT,
"Index value " CVM_TINT_FORMAT
" > " CVM_TINT_FORMAT));
73 mmMsg.insert(pair_Msg(
CVM_INDEX_GE,
"Index value " CVM_TINT_FORMAT
" >= " CVM_TINT_FORMAT));
74 mmMsg.insert(pair_Msg(
CVM_OUTOFRANGE_LTGT,
"Index value " CVM_TINT_FORMAT
" is out of [" CVM_TINT_FORMAT
"," CVM_TINT_FORMAT
"] range"));
75 mmMsg.insert(pair_Msg(
CVM_OUTOFRANGE_LTGE,
"Index value " CVM_TINT_FORMAT
" is out of [" CVM_TINT_FORMAT
"," CVM_TINT_FORMAT
") range"));
76 mmMsg.insert(pair_Msg(
CVM_OUTOFRANGE_LTGE1,
"First index value " CVM_TINT_FORMAT
" is out of [" CVM_TINT_FORMAT
"," CVM_TINT_FORMAT
") range"));
77 mmMsg.insert(pair_Msg(
CVM_OUTOFRANGE_LTGE2,
"Second index value " CVM_TINT_FORMAT
" is out of [" CVM_TINT_FORMAT
"," CVM_TINT_FORMAT
") range"));
78 mmMsg.insert(pair_Msg(
CVM_SIZESMISMATCH_GT,
"Sizes mismatch: " CVM_TINT_FORMAT
" > " CVM_TINT_FORMAT));
79 mmMsg.insert(pair_Msg(
CVM_SIZESMISMATCH_LT,
"Sizes mismatch: " CVM_TINT_FORMAT
" < " CVM_TINT_FORMAT));
81 mmMsg.insert(pair_Msg(
CFUN_PARSEERROR,
"Error while parsing \'%s\' for variables %s"));
82 mmMsg.insert(pair_Msg(
CFUN_DOMAINERROR,
"Domain error while calculating %s of %g"));
83 mmMsg.insert(pair_Msg(
CFUN_DOMAINERROR_C,
"Domain error while calculating %s of (%g,%g)"));
87 mmMsg.insert(pair_Msg(
CFUN_VARSDONTMATCH,
"Variables don\'t match: \'%s\' vs. \'%s\'"));
94 #if defined (CVM_STD_MUTEX)
95 std::unique_lock<std::mutex> l(cvm_mutex);
99 citr_Msg i = mmMsg.size() > 0 ? mmMsg.find(nException) : mmMsg.end();
100 return i == mmMsg.end() ? msUnknown : (*i).second;
105 #if defined (CVM_STD_MUTEX)
106 std::unique_lock<std::mutex> l(cvm_mutex);
111 itr_Msg i = mmMsg.find(nNewCause);
112 if (i != mmMsg.end()) {
113 (*i).second = (*i).second +
" | " + szNewMessage;
117 mmMsg.insert(pair_Msg(nNewCause, szNewMessage));
123 CVM_API
float _real<std::complex<float>,
float>(
const std::complex<float>& mT)
129 CVM_API
double _real<std::complex<double>,
double>(
const std::complex<double>& mT)
135 CVM_API
float _imag<std::complex<float>,
float>(
const std::complex<float>& mT)
141 CVM_API
double _imag<std::complex<double>,
double>(
const std::complex<double>& mT)
149 CVM_ASSERT(pFrom, ((nFromIncr)*(nSize - 1)+ 1)*
sizeof(
float))
150 CVM_ASSERT(pTo, ((nToIncr)*(nSize - 1)+ 1)*
sizeof(
float))
151 SCOPY(& nSize, pFrom, &nFromIncr, pTo, &nToIncr);
157 CVM_ASSERT(pFrom, ((nFromIncr)*(nSize - 1)+ 1)*
sizeof(
double))
158 CVM_ASSERT(pTo, ((nToIncr)*(nSize - 1)+ 1)*
sizeof(
double))
159 DCOPY(& nSize, pFrom, &nFromIncr, pTo, &nToIncr);
163 CVM_API
void __copy<std::complex<float> >(
tint nSize,
const std::complex<float>* pFrom,
tint nFromIncr, std::complex<float>* pTo,
tint nToIncr)
165 CVM_ASSERT(pFrom, ((nFromIncr)*(nSize - 1)+ 1)*
sizeof(std::complex<float>))
166 CVM_ASSERT(pTo, ((nToIncr)*(nSize - 1)+ 1)*
sizeof(std::complex<float>))
167 CCOPY(& nSize, pFrom, &nFromIncr, pTo, &nToIncr);
171 CVM_API
void __copy<std::complex<double> >(
tint nSize,
const std::complex<double>* pFrom,
tint nFromIncr, std::complex<double>* pTo,
tint nToIncr)
173 CVM_ASSERT(pFrom, ((nFromIncr)*(nSize - 1)+ 1)*
sizeof(std::complex<double>))
174 CVM_ASSERT(pTo, ((nToIncr)*(nSize - 1)+ 1)*
sizeof(std::complex<double>))
175 ZCOPY(& nSize, pFrom, &nFromIncr, pTo, &nToIncr);
183 for(
tint i = 0; i < nSize; ++i) {
184 pTo[i* nToIncr] = pFrom[i* nFromIncr];
191 CVM_ASSERT(p1, ((n1Incr)*(nSize - 1)+ 1)*
sizeof(
float))
192 CVM_ASSERT(p2, ((n2Incr)*(nSize - 1)+ 1)*
sizeof(
float))
193 SSWAP(& nSize, p1, &n1Incr, p2, &n2Incr);
199 CVM_ASSERT(p1, ((n1Incr)*(nSize - 1)+ 1)*
sizeof(
double))
200 CVM_ASSERT(p2, ((n2Incr)*(nSize - 1)+ 1)*
sizeof(
double))
201 DSWAP(& nSize, p1, &n1Incr, p2, &n2Incr);
205 CVM_API
void __swap<std::complex<float> >(
tint nSize, std::complex<float>* p1,
tint n1Incr, std::complex<float>* p2,
tint n2Incr)
207 CVM_ASSERT(p1, ((n1Incr)*(nSize - 1)+ 1)*
sizeof(std::complex<float>))
208 CVM_ASSERT(p2, ((n2Incr)*(nSize - 1)+ 1)*
sizeof(std::complex<float>))
209 CSWAP(& nSize, p1, &n1Incr, p2, &n2Incr);
213 CVM_API
void __swap<std::complex<double> >(
tint nSize, std::complex<double>* p1,
tint n1Incr, std::complex<double>* p2,
tint n2Incr)
215 CVM_ASSERT(p1, ((n1Incr)*(nSize - 1)+ 1)*
sizeof(std::complex<double>))
216 CVM_ASSERT(p2, ((n2Incr)*(nSize - 1)+ 1)*
sizeof(std::complex<double>))
217 ZSWAP(& nSize, p1, &n1Incr, p2, &n2Incr);
226 for(
tint i = 0; i < nSize; ++i) {
228 p1[i* n1Incr] = p2[i* n2Incr];
237 SGETRF(m._pm(), m._pn(), m, m._pld(), nPivots, &nOutInfo);
246 DGETRF(m._pm(), m._pn(), m, m._pld(), nPivots, &nOutInfo);
252 CVM_API
void __low_up<basic_scmatrix<float, std::complex<float> > >
256 CGETRF(m._pm(), m._pn(), m, m._pld(), nPivots, &nOutInfo);
262 CVM_API
void __low_up<basic_scmatrix<double, std::complex<double> > >
266 ZGETRF(m._pm(), m._pn(), m, m._pld(), nPivots, &nOutInfo);
272 CVM_API
void __low_up<basic_srbmatrix<float> >
279 SGBTRF(m._pm(), m._pn(), &nKL, &nKU, m, m._pld(), nPivots, &nOutInfo);
285 CVM_API
void __low_up<basic_srbmatrix<double> >
292 DGBTRF(m._pm(), m._pn(), &nKL, &nKU, m, m._pld(), nPivots, &nOutInfo);
298 CVM_API
void __low_up<basic_scbmatrix<float, std::complex<float> > >
305 CGBTRF(m._pm(), m._pn(), &nKL, &nKU, m, m._pld(), nPivots, &nOutInfo);
311 CVM_API
void __low_up<basic_scbmatrix<double, std::complex<double> > >
318 ZGBTRF(m._pm(), m._pn(), &nKL, &nKU, m, m._pld(), nPivots, &nOutInfo);
324 CVM_API
tint __cholesky<basic_srmatrix<float> >
329 #
if defined (CVM_PASS_STRING_LENGTH_TO_FTN_SUBROUTINES)
332 m._pm(), m, m._pld(), &nOutInfo);
337 CVM_API
tint __cholesky<basic_srmatrix<double> >
342 #
if defined (CVM_PASS_STRING_LENGTH_TO_FTN_SUBROUTINES)
345 m._pm(), m, m._pld(), &nOutInfo);
350 CVM_API
tint __cholesky<basic_scmatrix<float, std::complex<float> > >
355 #
if defined (CVM_PASS_STRING_LENGTH_TO_FTN_SUBROUTINES)
358 m._pm(), m, m._pld(), &nOutInfo);
363 CVM_API
tint __cholesky<basic_scmatrix<double, std::complex<double> > >
368 #
if defined (CVM_PASS_STRING_LENGTH_TO_FTN_SUBROUTINES)
371 m._pm(), m, m._pld(), &nOutInfo);
376 CVM_API
void __bunch_kaufman<basic_srmatrix<float> >
383 #
if defined (CVM_PASS_STRING_LENGTH_TO_FTN_SUBROUTINES)
386 m._pm(), m, m._pld(), nPivots, work, &lwork, &nOutInfo);
393 CVM_API
void __bunch_kaufman<basic_srmatrix<double> >
400 #
if defined (CVM_PASS_STRING_LENGTH_TO_FTN_SUBROUTINES)
403 m._pm(), m, m._pld(), nPivots, work, &lwork, &nOutInfo);
410 CVM_API
void __bunch_kaufman<basic_scmatrix<float, std::complex<float> > >
417 #
if defined (CVM_PASS_STRING_LENGTH_TO_FTN_SUBROUTINES)
420 m._pm(), m, m._pld(), nPivots, work, &lwork, &nOutInfo);
427 CVM_API
void __bunch_kaufman<basic_scmatrix<double, std::complex<double> > >
434 #
if defined (CVM_PASS_STRING_LENGTH_TO_FTN_SUBROUTINES)
437 m._pm(), m, m._pld(), nPivots, work, &lwork, &nOutInfo);
451 SGER(vCol._psize(), vRow._psize(), &dAlpha, vCol, vCol._pincr(), vRow, vRow._pincr(), m, m._pld());
462 DGER(vCol._psize(), vRow._psize(), &dAlpha, vCol, vCol._pincr(), vRow, vRow._pincr(), m, m._pld());
468 (basic_cmatrix<float, std::complex<float> >& m,
471 std::complex<float> cAlpha)
473 CVM_ASSERT(m, vCol.size()* vRow.size()*
sizeof(std::complex<float>))
474 CGERU(vCol._psize(), vRow._psize(), &cAlpha, vCol, vCol._pincr(), vRow, vRow._pincr(), m, m._pld());
478 CVM_API
void __geru<std::complex<
double>,
basic_cmatrix<
double, std::complex<
double> >,
basic_cvector<
double, std::complex<
double> > >
482 std::complex<
double> cAlpha)
484 CVM_ASSERT(m, vCol.size()* vRow.size()*
sizeof(std::complex<double>))
485 ZGERU(vCol._psize(), vRow._psize(), &cAlpha, vCol, vCol._pincr(), vRow, vRow._pincr(), m, m._pld());
489 CVM_API
void __gerc<std::complex<
float>,
basic_cmatrix<
float, std::complex<
float> >,
basic_cvector<
float, std::complex<
float> > >
493 std::complex<
float> cAlpha)
495 CVM_ASSERT(m, vCol.size()* vRow.size()*
sizeof(std::complex<float>))
496 CGERC(vCol._psize(), vRow._psize(), &cAlpha, vCol, vCol._pincr(), vRow, vRow._pincr(), m, m._pld());
500 CVM_API
void __gerc<std::complex<
double>,
basic_cmatrix<
double, std::complex<
double> >,
basic_cvector<
double, std::complex<
double> > >
504 std::complex<
double> cAlpha)
506 CVM_ASSERT(m, vCol.size()* vRow.size()*
sizeof(std::complex<double>))
507 ZGERC(vCol._psize(), vRow._psize(), &cAlpha, vCol, vCol._pincr(), vRow, vRow._pincr(), m, m._pld());
519 SPOEQU(m._pm(), m, m._pld(), vScalings, &dCond, &dMax, &nOutInfo);
532 DPOEQU(m._pm(), m, m._pld(), vScalings, &dCond, &dMax, &nOutInfo);
538 CVM_API
void __poequ<float, basic_schmatrix<float, std::complex<float> >,
basic_rvector<float> >
545 CPOEQU(m._pm(), m, m._pld(), vScalings, &dCond, &dMax, &nOutInfo);
558 ZPOEQU(m._pm(), m, m._pld(), vScalings, &dCond, &dMax, &nOutInfo);