28 template <
typename T,
typename OP>
40 if (a_nr != b_nr || a_nc != b_nc)
50 bool ja_lt_max = ja < ja_max;
54 bool jb_lt_max = jb < jb_max;
56 while (ja_lt_max || jb_lt_max)
59 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
65 ja_lt_max= ja < ja_max;
67 else if ((! ja_lt_max)
68 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
74 jb_lt_max= jb < jb_max;
78 if (op (a.
data (ja), b.
data (jb)) != 0.)
85 ja_lt_max= ja < ja_max;
87 jb_lt_max= jb < jb_max;
105 template <
typename T>
109 return plus_or_minus (a, b, std::minus<T> (),
"operator -=");
114 template <
typename T,
typename OP>
129 template <
typename T>
136 template <
typename T>
143 template <
typename T,
typename OP>
164 template <
typename T>
171 template <
typename T>
180 template <
typename T,
typename OP>
195 template <
typename T>
202 template <
typename T>
209 template <
typename T,
typename OP>
230 template <
typename T>
237 template <
typename T>
246 template <
typename T,
typename OP>
249 const char* op_name,
bool negate)
259 if (a_nr == 1 && a_nc == 1)
261 if (a.
elem (0,0) == 0.)
283 else if (b_nr == 1 && b_nc == 1)
285 if (b.
elem (0,0) == 0.)
304 else if (a_nr != b_nr || a_nc != b_nc)
316 bool ja_lt_max = ja < ja_max;
320 bool jb_lt_max = jb < jb_max;
322 while (ja_lt_max || jb_lt_max)
325 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
331 ja_lt_max= ja < ja_max;
333 else if ((! ja_lt_max)
334 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
340 jb_lt_max= jb < jb_max;
344 if (op (a.
data (ja), b.
data (jb)) != 0.)
351 ja_lt_max= ja < ja_max;
353 jb_lt_max= jb < jb_max;
365 template <
typename T>
369 return plus_or_minus (a, b, std::plus<T> (),
"operator +",
false);
372 template <
typename T>
376 return plus_or_minus (a, b, std::minus<T> (),
"operator -",
true);
379 template <
typename T>
391 if (a_nr == 1 && a_nc == 1)
393 if (a.
elem (0,0) == 0.)
408 else if (b_nr == 1 && b_nc == 1)
410 if (b.
elem (0,0) == 0.)
425 else if (a_nr != b_nr || a_nc != b_nc)
437 bool ja_lt_max = ja < ja_max;
441 bool jb_lt_max = jb < jb_max;
443 while (ja_lt_max || jb_lt_max)
446 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
448 ja++; ja_lt_max= ja < ja_max;
450 else if ((! ja_lt_max)
451 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
453 jb++; jb_lt_max= jb < jb_max;
457 if ((a.
data (ja) * b.
data (jb)) != 0.)
463 ja++; ja_lt_max= ja < ja_max;
464 jb++; jb_lt_max= jb < jb_max;
476 template <
typename T>
489 if (a_nr == 1 && a_nc == 1)
517 else if (b_nr == 1 && b_nc == 1)
545 else if (a_nr != b_nr || a_nc != b_nc)
555 bool ja_lt_max = ja < ja_max;
559 bool jb_lt_max = jb < jb_max;
561 while (ja_lt_max || jb_lt_max)
564 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
567 ja++; ja_lt_max= ja < ja_max;
569 else if ((! ja_lt_max)
570 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
573 jb++; jb_lt_max= jb < jb_max;
578 ja++; ja_lt_max= ja < ja_max;
579 jb++; jb_lt_max= jb < jb_max;
592 template <
typename T>
599 template <
typename T>
octave_idx_type cols(void) const
octave_idx_type rows(void) const
T & elem(octave_idx_type n)
MSparse< T > operator*(const MSparse< T > &a, const T &s)
identity matrix If supplied two scalar respectively For allows like xample val
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)
Template for N-dimensional array classes with like-type math operators.
octave_idx_type nnz(void) const
Actual number of nonzero terms.
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
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)
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
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)
=val(i)}if ode{val(i)}occurs in table i
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)
Vector representing the dimensions (size) of an Array.