42 template <
class T,
class OP>
54 if (a_nr != b_nr || a_nc != b_nc)
65 bool ja_lt_max= ja < ja_max;
69 bool jb_lt_max = jb < jb_max;
71 while (ja_lt_max || jb_lt_max)
74 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
80 ja_lt_max= ja < ja_max;
82 else if ((! ja_lt_max)
83 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
89 jb_lt_max= jb < jb_max;
93 if (op (a.
data (ja), b.
data (jb)) != 0.)
100 ja_lt_max= ja < ja_max;
102 jb_lt_max= jb < jb_max;
114 template <
typename T>
121 template <
typename T>
125 return plus_or_minus (a, b, std::minus<T> (),
"operator -=");
131 template <
class T,
class OP>
146 template <
typename T>
153 template <
typename T>
161 template <
class T,
class OP>
182 template <
typename T>
189 template <
typename T>
199 template <
class T,
class OP>
214 template <
typename T>
221 template <
typename T>
228 template <
class T,
class OP>
266 template <
class T,
class OP>
269 const char* op_name,
bool negate)
279 if (a_nr == 1 && a_nc == 1)
281 if (a.
elem (0,0) == 0.)
303 else if (b_nr == 1 && b_nc == 1)
305 if (b.
elem (0,0) == 0.)
324 else if (a_nr != b_nr || a_nc != b_nc)
336 bool ja_lt_max= ja < ja_max;
340 bool jb_lt_max = jb < jb_max;
342 while (ja_lt_max || jb_lt_max)
345 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
351 ja_lt_max= ja < ja_max;
353 else if ((! ja_lt_max)
354 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
360 jb_lt_max= jb < jb_max;
364 if (op (a.
data (ja), b.
data (jb)) != 0.)
371 ja_lt_max= ja < ja_max;
373 jb_lt_max= jb < jb_max;
389 return plus_or_minus (a, b, std::plus<T> (),
"operator +",
false);
396 return plus_or_minus (a, b, std::minus<T> (),
"operator -",
true);
411 if (a_nr == 1 && a_nc == 1)
413 if (a.
elem (0,0) == 0.)
428 else if (b_nr == 1 && b_nc == 1)
430 if (b.
elem (0,0) == 0.)
445 else if (a_nr != b_nr || a_nc != b_nc)
457 bool ja_lt_max= ja < ja_max;
461 bool jb_lt_max = jb < jb_max;
463 while (ja_lt_max || jb_lt_max)
466 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
468 ja++; ja_lt_max= ja < ja_max;
470 else if ((! ja_lt_max)
471 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
473 jb++; jb_lt_max= jb < jb_max;
477 if ((a.
data (ja) * b.
data (jb)) != 0.)
483 ja++; ja_lt_max= ja < ja_max;
484 jb++; jb_lt_max= jb < jb_max;
509 if (a_nr == 1 && a_nc == 1)
511 T val = a.
elem (0,0);
537 else if (b_nr == 1 && b_nc == 1)
539 T val = b.
elem (0,0);
565 else if (a_nr != b_nr || a_nc != b_nc)
575 bool ja_lt_max= ja < ja_max;
579 bool jb_lt_max = jb < jb_max;
581 while (ja_lt_max || jb_lt_max)
584 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
587 ja++; ja_lt_max= ja < ja_max;
589 else if ((! ja_lt_max)
590 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
593 jb++; jb_lt_max= jb < jb_max;
598 ja++; ja_lt_max= ja < ja_max;
599 jb++; jb_lt_max= jb < jb_max;
628 retval.
data (i) = - retval.
data (i);
octave_idx_type cols(void) const
void gripe_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
octave_idx_type rows(void) const
T & elem(octave_idx_type n)
MSparse< 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)
octave_idx_type * cidx(void)
T & elem(octave_idx_type n)
octave_idx_type nnz(void) const
MSparse< T > times_or_divide(const MSparse< T > &a, const T &s, OP op)
MSparse< T > quotient(const MSparse< T > &a, const MSparse< T > &b)
Sparse< T > maybe_compress(bool remove_zeros=false)
MSparse< T > times_or_divides(const T &s, const MSparse< T > &a, OP op)
MSparse< T > operator/(const MSparse< T > &a, const T &s)
octave_idx_type * ridx(void)
MSparse< T > & operator+=(MSparse< T > &a, const MSparse< T > &b)
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)
MArray< T > operator+(const MSparse< T > &a, const T &s)