30template <
typename T,
typename OP>
42 if (a_nr != b_nr || a_nc != b_nc)
43 octave::err_nonconformant (op_name, a_nr, a_nc, b_nr, b_nc);
52 bool ja_lt_max = ja < ja_max;
56 bool jb_lt_max = jb < jb_max;
58 while (ja_lt_max || jb_lt_max)
61 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
67 ja_lt_max= ja < ja_max;
69 else if ((! ja_lt_max)
76 jb_lt_max= jb < jb_max;
80 if (op (a.
data (ja), b.
data (jb)) != 0.)
87 ja_lt_max= ja < ja_max;
89 jb_lt_max= jb < jb_max;
111 return plus_or_minus (a, b, std::minus<T> (),
"operator -=");
116template <
typename T,
typename OP>
145template <
typename T,
typename OP>
182template <
typename T,
typename OP>
211template <
typename T,
typename OP>
248template <
typename T,
typename OP>
251 const char *op_name,
bool negate)
261 if (a_nr == 1 && a_nc == 1)
263 if (a.
elem (0, 0) == 0.)
285 else if (b_nr == 1 && b_nc == 1)
287 if (b.
elem (0, 0) == 0.)
306 else if (a_nr != b_nr || a_nc != b_nc)
307 octave::err_nonconformant (op_name, a_nr, a_nc, b_nr, b_nc);
318 bool ja_lt_max = ja < ja_max;
322 bool jb_lt_max = jb < jb_max;
324 while (ja_lt_max || jb_lt_max)
327 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
333 ja_lt_max= ja < ja_max;
335 else if ((! ja_lt_max)
342 jb_lt_max= jb < jb_max;
346 if (op (a.
data (ja), b.
data (jb)) != 0.)
353 ja_lt_max= ja < ja_max;
355 jb_lt_max= jb < jb_max;
371 return plus_or_minus (a, b, std::plus<T> (),
"operator +",
false);
378 return plus_or_minus (a, b, std::minus<T> (),
"operator -",
true);
393 if (a_nr == 1 && a_nc == 1)
395 if (a.
elem (0, 0) == 0.)
410 else if (b_nr == 1 && b_nc == 1)
412 if (b.
elem (0, 0) == 0.)
427 else if (a_nr != b_nr || a_nc != b_nc)
428 octave::err_nonconformant (
"product", a_nr, a_nc, b_nr, b_nc);
439 bool ja_lt_max = ja < ja_max;
443 bool jb_lt_max = jb < jb_max;
445 while (ja_lt_max || jb_lt_max)
448 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
450 ja++; ja_lt_max= ja < ja_max;
452 else if ((! ja_lt_max)
455 jb++; jb_lt_max= jb < jb_max;
459 if ((a.
data (ja) * b.
data (jb)) != 0.)
465 ja++; ja_lt_max= ja < ja_max;
466 jb++; jb_lt_max= jb < jb_max;
491 if (a_nr == 1 && a_nc == 1)
493 T val = a.
elem (0, 0);
519 else if (b_nr == 1 && b_nc == 1)
521 T val = b.
elem (0, 0);
547 else if (a_nr != b_nr || a_nc != b_nc)
548 octave::err_nonconformant (
"quotient", a_nr, a_nc, b_nr, b_nc);
557 bool ja_lt_max = ja < ja_max;
561 bool jb_lt_max = jb < jb_max;
563 while (ja_lt_max || jb_lt_max)
566 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
569 ja++; ja_lt_max= ja < ja_max;
571 else if ((! ja_lt_max)
575 jb++; jb_lt_max= jb < jb_max;
580 ja++; ja_lt_max= ja < ja_max;
581 jb++; jb_lt_max= jb < jb_max;
608 retval.
data (i) = - retval.
data (i);
MSparse< T > times_or_divide(const MSparse< T > &a, const T &s, OP op)
MSparse< T > times_or_divides(const T &s, const MSparse< T > &a, OP op)
MSparse< T > operator/(const MSparse< T > &a, const T &s)
MSparse< T > operator*(const MSparse< T > &a, const T &s)
MArray< T > operator-(const MSparse< T > &a, const T &s)
MSparse< T > & plus_or_minus(MSparse< T > &a, const MSparse< T > &b, OP op, const char *op_name)
MSparse< T > & operator-=(MSparse< T > &a, const MSparse< T > &b)
MArray< T > operator+(const MSparse< T > &a, const T &s)
MSparse< T > & operator+=(MSparse< T > &a, const MSparse< T > &b)
MSparse< T > product(const MSparse< T > &a, const MSparse< T > &b)
MSparse< T > quotient(const MSparse< T > &a, const MSparse< T > &b)
T & elem(octave_idx_type n)
Size of the specified dimension.
Template for N-dimensional array classes with like-type math operators.
octave_idx_type cols() const
T & elem(octave_idx_type n)
Sparse< T, Alloc > maybe_compress(bool remove_zeros=false)
octave_idx_type nnz() const
Actual number of nonzero terms.
octave_idx_type rows() const
Vector representing the dimensions (size) of an Array.