32 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER < 2)) || (CS_VER < 2))
33 typedef double _Complex cs_complex_t;
38 #define OCTAVE_C99_COMPLEX(buf, n) \
39 OCTAVE_LOCAL_BUFFER (double, buf ## tmp, (2 * (n))); \
40 cs_complex_t *buf = reinterpret_cast<cs_complex_t *> (buf ## tmp);
42 #define OCTAVE_C99_ZERO (0. + 0.iF)
43 #define OCTAVE_C99_ONE (1. + 0.iF)
45 #define OCTAVE_C99_COMPLEX(buf, n) \
46 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, (n));
47 #define OCTAVE_C99_ZERO cs_complex_t(0., 0.);
48 #define OCTAVE_C99_ONE cs_complex_t(1., 0.);
53 : count (1), nrows (0)
68 A.x =
const_cast<cs_complex_t *
>(
reinterpret_cast<const cs_complex_t *
>
72 #if defined (CS_VER) && (CS_VER >= 2)
80 (*current_liboctave_error_handler)
81 (
"SparseComplexQR: sparse matrix QR factorization filled");
84 (*current_liboctave_error_handler)
85 (
"SparseComplexQR: sparse matrix QR factorization not implemented");
115 ret.
xcidx (j) =
N->L->p[j];
118 ret.
xridx (j) =
N->L->i[j];
133 #
if defined (CS_VER) && (CS_VER >= 2)
134 ret.
xelem (i) =
S->pinv[i];
136 ret.
xelem (i) =
S->Pinv[i];
150 #
if defined (CS_VER) && (CS_VER >= 2)
151 ret.
xelem (
S->pinv[i]) = i;
153 ret.
xelem (
S->Pinv[i]) = i;
179 ret.
xcidx (j) =
N->U->p[j];
182 ret.
xridx (j) =
N->U->i[j];
199 const cs_complex_t *bvec =
200 reinterpret_cast<const cs_complex_t *
>(b.
fortran_vec ());
203 if (nr < 0 || nc < 0 || nr != b_nr)
204 (*current_liboctave_error_handler) (
"matrix dimension mismatch");
205 else if (nr == 0 || nc == 0 || b_nc == 0)
210 for (
volatile octave_idx_type j = 0, idx = 0; j < b_nc; j++, idx+=b_nr)
215 #if defined (CS_VER) && (CS_VER >= 2)
217 (
S->pinv, bvec + idx,
reinterpret_cast<cs_complex_t *
>(buf), b_nr);
220 (b_nr,
S->Pinv, bvec + idx,
reinterpret_cast<cs_complex_t *
>(buf));
228 (
N->L, i,
N->B[i],
reinterpret_cast<cs_complex_t *
>(buf));
249 if (nr < 0 || nc < 0)
250 (*current_liboctave_error_handler) (
"matrix dimension mismatch");
251 else if (nr == 0 || nc == 0)
265 #if defined (CS_VER) && (CS_VER >= 2)
267 (
S->pinv, bvec,
reinterpret_cast<cs_complex_t *
>(buf), nr);
270 (nr,
S->Pinv, bvec,
reinterpret_cast<cs_complex_t *
>(buf));
278 (
N->L, i,
N->B[i],
reinterpret_cast<cs_complex_t *
>(buf));
303 if (nr < 0 || nc < 0 || nr != b_nr)
304 (*current_liboctave_error_handler)
305 (
"matrix dimension mismatch in solution of minimum norm problem");
306 else if (nr == 0 || nc == 0 || b_nc == 0)
314 cs_complex_t *vec =
reinterpret_cast<cs_complex_t *
> (x.
fortran_vec ());
321 Xx[j] = b.
xelem (j,i);
325 #if defined (CS_VER) && (CS_VER >= 2)
327 (q.
S ()->pinv,
reinterpret_cast<cs_complex_t *
>(Xx), buf, nr);
330 (nr, q.
S ()->Pinv,
reinterpret_cast<cs_complex_t *
>(Xx), buf);
342 #if defined (CS_VER) && (CS_VER >= 2)
358 cs_complex_t *vec =
reinterpret_cast<cs_complex_t *
> (x.
fortran_vec ());
362 #if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
369 B[i] =
conj (reinterpret_cast<Complex *>(q.
N ()->B)[i]);
375 Xx[j] = b.
xelem (j,i);
379 #if defined (CS_VER) && (CS_VER >= 2)
381 (q.
S ()->q,
reinterpret_cast<cs_complex_t *
>(Xx), buf, nr);
384 (nr, q.
S ()->Q,
reinterpret_cast<cs_complex_t *
>(Xx), buf);
393 #if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
397 (q.
N ()->L, j,
reinterpret_cast<cs_complex_t *
>(
B)[j], buf);
402 #if defined (CS_VER) && (CS_VER >= 2)
431 if (nr < 0 || nc < 0 || nr != b_nr)
432 (*current_liboctave_error_handler)
433 (
"matrix dimension mismatch in solution of minimum norm problem");
434 else if (nr == 0 || nc == 0 || b_nc == 0)
451 Xx[j] = b.
xelem (j,i);
455 #if defined (CS_VER) && (CS_VER >= 2)
457 (q.
S ()->pinv,
reinterpret_cast<cs_complex_t *
>(Xx), buf, nr);
460 (nr, q.
S ()->Pinv,
reinterpret_cast<cs_complex_t *
>(Xx), buf);
472 #if defined (CS_VER) && (CS_VER >= 2)
474 (q.
S ()->q, buf,
reinterpret_cast<cs_complex_t *
>(Xx), nc);
477 (nc, q.
S ()->Q, buf,
reinterpret_cast<cs_complex_t *
>(Xx));
490 sz = (sz > 10 ? sz : 10) + x_nz;
516 #if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
523 B[i] =
conj (reinterpret_cast<Complex *>(q.
N ()->B)[i]);
529 Xx[j] = b.
xelem (j,i);
533 #if defined (CS_VER) && (CS_VER >= 2)
535 (q.
S ()->q,
reinterpret_cast<cs_complex_t *
>(Xx), buf, nr);
538 (nr, q.
S ()->Q,
reinterpret_cast<cs_complex_t *
>(Xx), buf);
546 #if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
550 (q.
N ()->L, j,
reinterpret_cast<cs_complex_t *
>(
B)[j], buf);
555 #if defined (CS_VER) && (CS_VER >= 2)
557 (q.
S ()->pinv, buf,
reinterpret_cast<cs_complex_t *
>(Xx), nc);
560 (nc, q.
S ()->Pinv, buf,
reinterpret_cast<cs_complex_t *
>(Xx));
573 sz = (sz > 10 ? sz : 10) + x_nz;
603 const cs_complex_t *bvec =
604 reinterpret_cast<const cs_complex_t *
>(b.
fortran_vec ());
607 if (nr < 0 || nc < 0 || nr != b_nr)
608 (*current_liboctave_error_handler)
609 (
"matrix dimension mismatch in solution of minimum norm problem");
610 else if (nr == 0 || nc == 0 || b_nc == 0)
618 cs_complex_t *vec =
reinterpret_cast<cs_complex_t *
>
622 i++, idx+=nc, bidx+=b_nr)
628 #if defined (CS_VER) && (CS_VER >= 2)
643 #if defined (CS_VER) && (CS_VER >= 2)
659 cs_complex_t *vec =
reinterpret_cast<cs_complex_t *
> (x.
fortran_vec ());
662 #if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
669 B[i] =
conj (reinterpret_cast<Complex *>(q.
N ()->B)[i]);
672 i++, idx+=nc, bidx+=b_nr)
678 #if defined (CS_VER) && (CS_VER >= 2)
689 #if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
693 (q.
N ()->L, j,
reinterpret_cast<cs_complex_t *
>(
B)[j], buf);
698 #if defined (CS_VER) && (CS_VER >= 2)
727 if (nr < 0 || nc < 0 || nr != b_nr)
728 (*current_liboctave_error_handler)
729 (
"matrix dimension mismatch in solution of minimum norm problem");
730 else if (nr == 0 || nc == 0 || b_nc == 0)
747 Xx[j] = b.
xelem (j,i);
751 #if defined (CS_VER) && (CS_VER >= 2)
753 (q.
S ()->pinv,
reinterpret_cast<cs_complex_t *
>(Xx), buf, nr);
756 (nr, q.
S ()->Pinv,
reinterpret_cast<cs_complex_t *
>(Xx), buf);
768 #if defined (CS_VER) && (CS_VER >= 2)
770 (q.
S ()->q, buf,
reinterpret_cast<cs_complex_t *
>(Xx), nc);
773 (nc, q.
S ()->Q, buf,
reinterpret_cast<cs_complex_t *
>(Xx));
786 sz = (sz > 10 ? sz : 10) + x_nz;
811 #if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
818 B[i] =
conj (reinterpret_cast<Complex *>(q.
N ()->B)[i]);
824 Xx[j] = b.
xelem (j,i);
828 #if defined (CS_VER) && (CS_VER >= 2)
830 (q.
S ()->q,
reinterpret_cast<cs_complex_t *
>(Xx), buf, nr);
833 (nr, q.
S ()->Q,
reinterpret_cast<cs_complex_t *
>(Xx), buf);
841 #if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
845 (q.
N ()->L, j,
reinterpret_cast<cs_complex_t *
>(
B)[j], buf);
850 #if defined (CS_VER) && (CS_VER >= 2)
852 (q.
S ()->pinv, buf,
reinterpret_cast<cs_complex_t *
>(Xx), nc);
855 (nc, q.
S ()->Pinv, buf,
reinterpret_cast<cs_complex_t *
>(Xx));
868 sz = (sz > 10 ? sz : 10) + x_nz;
SparseComplexMatrix V(void) const
octave_idx_type * xridx(void)
octave_idx_type cols(void) const
octave_idx_type rows(void) const
T & xelem(octave_idx_type n)
SparseComplexQR_rep(const SparseComplexMatrix &a, int order)
#define CXSPARSE_ZNAME(name)
F77_RET_T const octave_idx_type Complex * A
#define OCTAVE_C99_COMPLEX(buf, n)
octave_idx_type * xcidx(void)
ColumnVector P(void) const
SparseComplexMatrix R(const bool econ) const
octave_idx_type rows(void) const
octave_idx_type nnz(void) const
ComplexColumnVector conj(const ComplexColumnVector &a)
ComplexMatrix hermitian(void) const
void change_capacity(octave_idx_type nz)
Sparse< T > maybe_compress(bool remove_zeros=false)
ComplexMatrix C(const ComplexMatrix &b) const
SparseComplexMatrix hermitian(void) const
T & xelem(octave_idx_type n)
F77_RET_T const octave_idx_type Complex const octave_idx_type Complex * B
F77_RET_T const octave_idx_type & N
#define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
ComplexMatrix Q(void) const
friend ComplexMatrix qrsolve(const SparseComplexMatrix &a, const Matrix &b, octave_idx_type &info)
#define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
std::complex< double > Complex
const T * fortran_vec(void) const
ColumnVector Pinv(void) const
octave_idx_type cols(void) const
F77_RET_T const double * x
~SparseComplexQR_rep(void)