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;