comparison liboctave/MDiagArray2.cc @ 8367:445d27d79f4e

support permutation matrix objects
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 04 Dec 2008 08:31:56 +0100
parents a1dbe9d80eee
children eb63fbe60fab
comparison
equal deleted inserted replaced
8366:8b1a2555c4e2 8367:445d27d79f4e
28 #include "MDiagArray2.h" 28 #include "MDiagArray2.h"
29 #include "Array-util.h" 29 #include "Array-util.h"
30 #include "lo-error.h" 30 #include "lo-error.h"
31 31
32 #include "MArray-defs.h" 32 #include "MArray-defs.h"
33
34 template <class T>
35 bool
36 MDiagArray2<T>::is_multiple_of_identity (T val) const
37 {
38 bool retval = this->rows () == this->cols ();
39 if (retval)
40 {
41 octave_idx_type len = this->length (), i = 0;
42 for (;i < len; i++)
43 if (DiagArray2<T>::elem (i, i) != val) break;
44 retval = i == len;
45 }
46
47 return retval;
48 }
33 49
34 // Some functions return a reference to this object after a failure. 50 // Some functions return a reference to this object after a failure.
35 template <class T> MDiagArray2<T> MDiagArray2<T>::nil_array; 51 template <class T> MDiagArray2<T> MDiagArray2<T>::nil_array;
36 52
37 // Two dimensional diagonal array with math ops. 53 // Two dimensional diagonal array with math ops.