26 #if defined (HAVE_CONFIG_H)
58 maxnz = (maxnz < 0 ?
A.nnz () : maxnz);
83 B.xcidx (j - cst) = nz;
91 if (
r >= rst &&
r < rend)
93 B.xdata (nz) =
A.data (p);
94 B.xridx (nz++) =
r - rst;
99 B.xcidx (cend - cst) = nz;
114 B.xcidx (j - cst) = nz;
122 if (
r >= rst &&
r < rend)
124 X[
r-rst] =
A.data (p);
125 B.xridx (nz++) =
r - rst;
129 sort.
sort (ri +
B.xcidx (j - cst), nz -
B.xcidx (j - cst));
132 B.xdata (p) = X[
B.xridx (p)];
135 B.xcidx (cend - cst) = nz;
141 template <
typename T>
165 result.xelem (i, j) =
m.elem (r1+i, c1+j);
171 template <
typename T>
178 const T *bx = b.
data ();
193 ax[
Q[
r + i] + aoff] = bx[i + boff];
198 template <
typename T>
224 if (Qinv[a.
xridx (j)] <
r || Qinv[a.
xridx (j)] >=
r + b_rows)
241 a.
xdata (i) = tmp.xdata (i);
242 a.
xridx (i) = tmp.xridx (i);
246 a.
xcidx (i) = tmp.xcidx (i);
256 if (Qinv[tmp.xridx (j)] <
r || Qinv[tmp.xridx (j)] >=
r + b_rows)
258 X[tmp.xridx (j)] = tmp.xdata (j);
259 a.
xridx (ii++) = tmp.xridx (j);
283 a.
xdata (ii) = tmp.xdata (j);
284 a.
xridx (ii++) = tmp.xridx (j);
291 template <
typename T,
typename RT>
298 const T *Bx = b.
data ();
310 Btx[p[i] + off] = Bx[ i + off];
315 template <
typename T,
typename RT>
355 #if defined (HAVE_CXSPARSE)
358 solve_singularity_warning (
double)
366 template <
typename RT,
typename ST,
typename T>
372 #if defined (HAVE_CXSPARSE)
380 if (nr < 0 || nc < 0 || nr != b_nr)
381 (*current_liboctave_error_handler)
382 (
"matrix dimension mismatch in solution of minimum norm problem");
384 if (nr == 0 || nc == 0 || b_nc == 0)
385 retval = RT (nc, b_nc, 0.0);
396 csm.nzmax = a.nnz ();
415 dmsolve_permute (btmp, b, pinv);
418 retval.resize (nc, b_nc);
421 if (dm->rr[2] < nr && dm->cc[3] < nc)
423 ST
m = dmsolve_extract (a, pinv, q, dm->rr[2], nr, dm->cc[3], nc,
424 nnz_remaining,
true);
425 nnz_remaining -=
m.nnz ();
431 dmsolve_insert (retval, mtmp, q, dm->cc[3], 0);
433 if (dm->rr[2] > 0 && ! info)
435 m = dmsolve_extract (a, pinv, q, 0, dm->rr[2],
436 dm->cc[3], nc, nnz_remaining,
true);
437 nnz_remaining -=
m.nnz ();
438 RT ctmp = dmsolve_extract (btmp,
nullptr,
nullptr,
439 0, dm->rr[2], 0, b_nc);
440 btmp.insert (ctmp -
m * mtmp, 0, 0);
446 if (dm->rr[1] < dm->rr[2] && dm->cc[2] < dm->cc[3] && ! info)
448 ST
m = dmsolve_extract (a, pinv, q, dm->rr[1], dm->rr[2],
449 dm->cc[2], dm->cc[3], nnz_remaining,
false);
450 nnz_remaining -=
m.nnz ();
451 RT btmp2 = dmsolve_extract (btmp,
nullptr,
nullptr,
452 dm->rr[1], dm->rr[2],
456 RT mtmp =
m.solve (mtyp, btmp2, info, rcond,
457 solve_singularity_warning,
false);
464 dmsolve_insert (retval, mtmp, q, dm->cc[2], 0);
465 if (dm->rr[1] > 0 && ! info)
467 m = dmsolve_extract (a, pinv, q, 0, dm->rr[1], dm->cc[2],
468 dm->cc[3], nnz_remaining,
true);
469 nnz_remaining -=
m.nnz ();
470 RT ctmp = dmsolve_extract (btmp,
nullptr,
nullptr,
471 0, dm->rr[1], 0, b_nc);
472 btmp.insert (ctmp -
m * mtmp, 0, 0);
477 if (dm->rr[1] > 0 && dm->cc[2] > 0 && ! info)
479 ST
m = dmsolve_extract (a, pinv, q, 0, dm->rr[1], 0,
480 dm->cc[2], nnz_remaining,
true);
486 dmsolve_insert (retval, mtmp, q, 0, 0);
494 octave_unused_parameter (a);
495 octave_unused_parameter (b);
496 octave_unused_parameter (info);
498 (*current_liboctave_error_handler)
499 (
"support for CXSparse was unavailable or disabled when liboctave was built");
T * fortran_vec()
Size of the specified dimension.
octave_idx_type rows() const
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
const T * data() const
Size of the specified dimension.
octave_idx_type cols() const
Template for N-dimensional array classes with like-type math operators.
octave_idx_type cols() const
octave_idx_type * xcidx()
octave_idx_type nnz() const
Actual number of nonzero terms.
octave_idx_type rows() const
octave_idx_type * xridx()
Vector representing the dimensions (size) of an Array.
void sort(T *data, octave_idx_type nel)
F77_RET_T const F77_INT F77_CMPLX const F77_INT F77_CMPLX * B
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Q
F77_RET_T const F77_INT F77_CMPLX * A
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
octave_int< uint64_t > octave_uint64
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_idx_type * to_octave_idx_type_ptr(suitesparse_integer *i)
suitesparse_integer * to_suitesparse_intptr(octave_idx_type *i)
#define CXSPARSE_DNAME(name)
template SparseMatrix dmsolve< SparseMatrix, SparseMatrix, SparseMatrix >(const SparseMatrix &, const SparseMatrix &, octave_idx_type &)
template Matrix dmsolve< Matrix, SparseMatrix, Matrix >(const SparseMatrix &, const Matrix &, octave_idx_type &)
template ComplexMatrix dmsolve< ComplexMatrix, SparseComplexMatrix, ComplexMatrix >(const SparseComplexMatrix &, const ComplexMatrix &, octave_idx_type &)
template ComplexMatrix dmsolve< ComplexMatrix, SparseComplexMatrix, Matrix >(const SparseComplexMatrix &, const Matrix &, octave_idx_type &)
template SparseComplexMatrix dmsolve< SparseComplexMatrix, SparseComplexMatrix, SparseComplexMatrix >(const SparseComplexMatrix &, const SparseComplexMatrix &, octave_idx_type &)
template ComplexMatrix dmsolve< ComplexMatrix, SparseMatrix, ComplexMatrix >(const SparseMatrix &, const ComplexMatrix &, octave_idx_type &)
template SparseComplexMatrix dmsolve< SparseComplexMatrix, SparseMatrix, SparseComplexMatrix >(const SparseMatrix &, const SparseComplexMatrix &, octave_idx_type &)
RT dmsolve(const ST &a, const T &b, octave_idx_type &info)
template SparseComplexMatrix dmsolve< SparseComplexMatrix, SparseComplexMatrix, SparseMatrix >(const SparseComplexMatrix &, const SparseMatrix &, octave_idx_type &)
Matrix qrsolve(const SparseMatrix &a, const MArray< double > &b, octave_idx_type &info)