24 #if defined (HAVE_CONFIG_H) 45 template <
typename SPARSE_T>
56 #if defined (HAVE_CXSPARSE) 70 #if defined (HAVE_CXSPARSE) 79 template <
typename SPARSE_T>
96 #if defined (HAVE_CXSPARSE) 103 SPARSE_T
V (
void)
const;
109 SPARSE_T
R (
bool econ)
const;
111 typename SPARSE_T::dense_matrix_type
112 C (
const typename SPARSE_T::dense_matrix_type&
b)
const;
114 typename SPARSE_T::dense_matrix_type
125 template <
typename RHS_T,
typename RET_T>
129 template <
typename RHS_T,
typename RET_T>
134 template <
typename SPARSE_T>
138 #if defined (HAVE_CXSPARSE) 154 template <
typename SPARSE_T>
158 #if defined (HAVE_CXSPARSE) 181 : count (1), nrows (
a.rows ()), ncols (
a.columns ())
183 , S (
nullptr),
N (
nullptr)
186 #if defined (HAVE_CXSPARSE) 199 A.x =
const_cast<double *
> (
a.data ());
208 (*current_liboctave_error_handler)
209 (
"sparse_qr: sparse matrix QR factorization filled");
215 octave_unused_parameter (order);
217 (*current_liboctave_error_handler)
218 (
"sparse_qr: support for CXSparse was unavailable or disabled when liboctave was built");
226 #if defined (HAVE_CXSPARSE) 236 #if defined (HAVE_CXSPARSE) 254 ret.
xcidx (j) =
N->L->p[j];
258 ret.
xridx (j) =
N->L->i[j];
259 ret.
xdata (j) =
N->L->x[j];
275 #if defined (HAVE_CXSPARSE) 291 SparseMatrix ret ((econ ? (nc > nrows ? nrows : nc) : nrows), nc, nz);
294 ret.
xcidx (j) =
N->U->p[j];
298 ret.
xridx (j) =
N->U->i[j];
299 ret.
xdata (j) =
N->U->x[j];
306 octave_unused_parameter (econ);
317 #if defined (HAVE_CXSPARSE) 325 const double *bvec =
b.fortran_vec ();
330 if (nr < 0 || nc < 0 || nr !=
b_nr)
331 (*current_liboctave_error_handler) (
"matrix dimension mismatch");
333 if (nr == 0 || nc == 0 ||
b_nc == 0)
372 octave_unused_parameter (
b);
383 #if defined (HAVE_CXSPARSE) 389 if (nr < 0 || nc < 0)
390 (*current_liboctave_error_handler) (
"matrix dimension mismatch");
392 if (nr == 0 || nc == 0)
393 ret =
Matrix (nc, nr, 0.0);
450 #if defined (HAVE_CXSPARSE) 458 const double *bvec =
b.data ();
461 double *vec =
x.fortran_vec ();
466 i++, idx+=nc, bidx+=
b_nr)
498 octave_unused_parameter (
b);
513 #if defined (HAVE_CXSPARSE) 524 const double *bvec =
b.data ();
527 double *vec =
x.fortran_vec ();
534 i++, idx+=nc, bidx+=
b_nr)
566 octave_unused_parameter (
b);
581 #if defined (HAVE_CXSPARSE) 603 Xx[j] =
b.xelem (j,
i);
636 sz = (
sz > 10 ?
sz : 10) + x_nz;
637 x.change_capacity (
sz);
655 octave_unused_parameter (
b);
670 #if defined (HAVE_CXSPARSE) 696 Xx[j] =
b.xelem (j,
i);
729 sz = (
sz > 10 ?
sz : 10) + x_nz;
730 x.change_capacity (
sz);
750 octave_unused_parameter (
b);
765 #if defined (HAVE_CXSPARSE) 832 vec[j+idx] =
Complex (Xx[j], Xz[j]);
841 octave_unused_parameter (
b);
856 #if defined (HAVE_CXSPARSE) 930 vec[j+idx] =
Complex (Xx[j], Xz[j]);
939 octave_unused_parameter (
b);
951 : count (1), nrows (
a.rows ()), ncols (
a.columns ())
953 , S (
nullptr),
N (
nullptr)
956 #if defined (HAVE_CXSPARSE) 969 A.x =
const_cast<cs_complex_t *
> 970 (
reinterpret_cast<const cs_complex_t *
> (
a.data ()));
979 (*current_liboctave_error_handler)
980 (
"sparse_qr: sparse matrix QR factorization filled");
986 octave_unused_parameter (order);
988 (*current_liboctave_error_handler)
989 (
"sparse_qr: support for CXSparse was unavailable or disabled when liboctave was built");
997 #if defined (HAVE_CXSPARSE) 1007 #if defined (HAVE_CXSPARSE) 1024 ret.
xcidx (j) =
N->L->p[j];
1028 ret.
xridx (j) =
N->L->i[j];
1045 #if defined (HAVE_CXSPARSE) 1064 ret.
xcidx (j) =
N->U->p[j];
1068 ret.
xridx (j) =
N->U->i[j];
1076 octave_unused_parameter (econ);
1087 #if defined (HAVE_CXSPARSE) 1092 const cs_complex_t *bvec
1093 =
reinterpret_cast<const cs_complex_t *
> (
b.fortran_vec ());
1097 if (nr < 0 || nc < 0 || nr !=
b_nr)
1098 (*current_liboctave_error_handler) (
"matrix dimension mismatch");
1100 if (nr == 0 || nc == 0 ||
b_nc == 0)
1116 reinterpret_cast<cs_complex_t *
> (buf),
1126 reinterpret_cast<cs_complex_t *
> (buf));
1131 vec[
i+idx] = buf[
i];
1139 octave_unused_parameter (
b);
1150 #if defined (HAVE_CXSPARSE) 1156 if (nr < 0 || nc < 0)
1157 (*current_liboctave_error_handler) (
"matrix dimension mismatch");
1159 if (nr == 0 || nc == 0)
1166 bvec[
i] = cs_complex_t (0.0, 0.0);
1174 bvec[j] = cs_complex_t (1.0, 0.0);
1180 reinterpret_cast<cs_complex_t *
> (buf),
1190 reinterpret_cast<cs_complex_t *
> (buf));
1195 vec[
i+idx] = buf[
i];
1197 bvec[j] = cs_complex_t (0.0, 0.0);
1219 #if defined (HAVE_CXSPARSE) 1300 sz = (
sz > 10 ?
sz : 10) + x_nz;
1301 x.change_capacity (
sz);
1319 octave_unused_parameter (
b);
1335 #if defined (HAVE_CXSPARSE) 1420 sz = (
sz > 10 ?
sz : 10) + x_nz;
1421 x.change_capacity (
sz);
1435 x.maybe_compress ();
1441 octave_unused_parameter (
b);
1457 #if defined (HAVE_CXSPARSE) 1466 cs_complex_t *vec =
reinterpret_cast<cs_complex_t *
> (
x.fortran_vec ());
1476 Xx[j] =
b.xelem (j,
i);
1479 buf[j] = cs_complex_t (0.0, 0.0);
1483 reinterpret_cast<cs_complex_t *
>(Xx),
1508 octave_unused_parameter (
b);
1524 #if defined (HAVE_CXSPARSE) 1536 cs_complex_t *vec =
reinterpret_cast<cs_complex_t *
> (
x.fortran_vec ());
1552 Xx[j] =
b.xelem (j,
i);
1555 buf[j] = cs_complex_t (0.0, 0.0);
1558 CXSPARSE_ZNAME (_pvec) (S->q,
reinterpret_cast<cs_complex_t *
>(Xx),
1583 octave_unused_parameter (
b);
1599 #if defined (HAVE_CXSPARSE) 1621 Xx[j] =
b.xelem (j,
i);
1624 buf[j] = cs_complex_t (0.0, 0.0);
1628 reinterpret_cast<cs_complex_t *
>(Xx),
1644 reinterpret_cast<cs_complex_t *
> (Xx),
1658 sz = (
sz > 10 ?
sz : 10) + x_nz;
1659 x.change_capacity (
sz);
1673 x.maybe_compress ();
1679 octave_unused_parameter (
b);
1695 #if defined (HAVE_CXSPARSE) 1725 Xx[j] =
b.xelem (j,
i);
1728 buf[j] = cs_complex_t (0.0, 0.0);
1732 reinterpret_cast<cs_complex_t *
>(Xx),
1748 reinterpret_cast<cs_complex_t *
> (Xx),
1762 sz = (
sz > 10 ?
sz : 10) + x_nz;
1763 x.change_capacity (
sz);
1777 x.maybe_compress ();
1783 octave_unused_parameter (
b);
1799 #if defined (HAVE_CXSPARSE) 1807 const cs_complex_t *bvec =
reinterpret_cast<const cs_complex_t *
> 1811 cs_complex_t *vec =
reinterpret_cast<cs_complex_t *
> 1817 i++, idx+=nc, bidx+=
b_nr)
1822 buf[j] = cs_complex_t (0.0, 0.0);
1849 octave_unused_parameter (
b);
1865 #if defined (HAVE_CXSPARSE) 1876 const cs_complex_t *bvec =
reinterpret_cast<const cs_complex_t *
> 1880 cs_complex_t *vec =
reinterpret_cast<cs_complex_t *
> (
x.fortran_vec ());
1891 i++, idx+=nc, bidx+=
b_nr)
1896 buf[j] = cs_complex_t (0.0, 0.0);
1923 octave_unused_parameter (
b);
1938 #if defined (HAVE_CXSPARSE) 1960 Xx[j] =
b.xelem (j,
i);
1963 buf[j] = cs_complex_t (0.0, 0.0);
1967 reinterpret_cast<cs_complex_t *
>(Xx),
1983 reinterpret_cast<cs_complex_t *
> (Xx),
1997 sz = (
sz > 10 ?
sz : 10) + x_nz;
1998 x.change_capacity (
sz);
2012 x.maybe_compress ();
2018 octave_unused_parameter (
b);
2033 #if defined (HAVE_CXSPARSE) 2063 Xx[j] =
b.xelem (j,
i);
2066 buf[j] = cs_complex_t (0.0, 0.0);
2069 CXSPARSE_ZNAME (_pvec) (S->q,
reinterpret_cast<cs_complex_t *
>(Xx),
2085 reinterpret_cast<cs_complex_t *
>(Xx), nc);
2098 sz = (
sz > 10 ?
sz : 10) + x_nz;
2099 x.change_capacity (
sz);
2113 x.maybe_compress ();
2119 octave_unused_parameter (
b);
2126 template <
typename SPARSE_T>
2131 template <
typename SPARSE_T>
2136 template <
typename SPARSE_T>
2143 template <
typename SPARSE_T>
2146 if (--rep->count == 0)
2150 template <
typename SPARSE_T>
2156 if (--rep->count == 0)
2166 template <
typename SPARSE_T>
2173 template <
typename SPARSE_T>
2180 template <
typename SPARSE_T>
2187 template <
typename SPARSE_T>
2194 template <
typename SPARSE_T>
2198 return rep->R (econ);
2201 template <
typename SPARSE_T>
2202 typename SPARSE_T::dense_matrix_type
2208 template <
typename SPARSE_T>
2209 typename SPARSE_T::dense_matrix_type
2220 template <
typename SPARSE_T>
2225 enum { order = -1 };
2244 template <
typename SPARSE_T>
2245 template <
typename RHS_T,
typename RET_T>
2260 if (nr < 0 || nc < 0 || nr !=
b_nr)
2261 (*current_liboctave_error_handler)
2262 (
"matrix dimension mismatch in solution of minimum norm problem");
2264 if (nr == 0 || nc == 0 ||
b_nc == 0)
2268 return RET_T (nc,
b_nc, 0.0);
2274 return q.
ok () ? q.
tall_solve<RHS_T, RET_T> (
b, info) : RET_T ();
2280 return q.
ok () ? q.wide_solve<RHS_T, RET_T> (
b, info) : RET_T ();
2284 template <
typename SPARSE_T>
2285 template <
typename RHS_T,
typename RET_T>
2289 return rep->template tall_solve<RHS_T, RET_T> (
b, info);
2292 template <
typename SPARSE_T>
2293 template <
typename RHS_T,
typename RET_T>
2297 return rep->template wide_solve<RHS_T, RET_T> (
b, info);
2368 template class sparse_qr<SparseMatrix>;
2370 template class sparse_qr<SparseComplexMatrix>;
for(octave_idx_type n=0;n< hcv.numel();n++)
F77_RET_T const F77_INT F77_CMPLX const F77_INT F77_CMPLX * B
Matrix qrsolve(const SparseMatrix &a, const MArray< double > &b, octave_idx_type &info)
SPARSE_T::dense_matrix_type Q(void) const
RET_T wide_solve(const RHS_T &b, octave_idx_type &info) const
F77_RET_T const F77_INT & N
ColumnVector Pinv(void) const
const T * fortran_vec(void) const
RET_T tall_solve(const RHS_T &b, octave_idx_type &info) const
sparse_qr & operator=(const sparse_qr &a)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
ColumnVector P(void) const
SPARSE_T R(bool econ) const
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
SPARSE_T::dense_matrix_type C(const typename SPARSE_T::dense_matrix_type &b) const
SPARSE_T::dense_matrix_type Q(void) const
Matrix transpose(void) const
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
F77_RET_T const F77_INT F77_CMPLX * A
octave_idx_type * xridx(void)
SPARSE_T::dense_matrix_type C(const typename SPARSE_T::dense_matrix_type &b) const
SPARSE_T R(bool econ=false) const
T & xelem(octave_idx_type n)
cxsparse_types< SPARSE_T >::numeric_type * N
#define CXSPARSE_DNAME(name)
defaults to zero A value of zero computes the digamma a value the trigamma and so on The digamma function is defined
#define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
static RET_T solve(const SPARSE_T &a, const RHS_T &b, octave_idx_type &info)
cxsparse_types< SPARSE_T >::symbolic_type * S
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
sparse_qr_rep(const SPARSE_T &a, int order)
#define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
std::complex< double > Complex
octave_idx_type * xcidx(void)
ColumnVector Pinv(void) const
ColumnVector P(void) const
#define CXSPARSE_ZNAME(name)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
suitesparse_integer * to_suitesparse_intptr(octave_idx_type *i)
ComplexMatrix hermitian(void) const