Mercurial > octave
comparison liboctave/PermMatrix.h @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
11585:1473d0cf86d2 | 11586:12df7854fa7c |
---|---|
36 | 36 |
37 PermMatrix (void) : Array<octave_idx_type> (), _colp (false) { } | 37 PermMatrix (void) : Array<octave_idx_type> (), _colp (false) { } |
38 | 38 |
39 PermMatrix (octave_idx_type n); | 39 PermMatrix (octave_idx_type n); |
40 | 40 |
41 PermMatrix (const Array<octave_idx_type>& p, bool colp = false, | 41 PermMatrix (const Array<octave_idx_type>& p, bool colp = false, |
42 bool check = true); | 42 bool check = true); |
43 | 43 |
44 PermMatrix (const PermMatrix& m) | 44 PermMatrix (const PermMatrix& m) |
45 : Array<octave_idx_type> (m), _colp(m._colp) { } | 45 : Array<octave_idx_type> (m), _colp(m._colp) { } |
46 | |
47 PermMatrix (const idx_vector& idx, bool colp = false, octave_idx_type n = 0); | |
48 | 46 |
49 octave_idx_type dim1 (void) const | 47 PermMatrix (const idx_vector& idx, bool colp = false, octave_idx_type n = 0); |
48 | |
49 octave_idx_type dim1 (void) const | |
50 { return Array<octave_idx_type>::length (); } | 50 { return Array<octave_idx_type>::length (); } |
51 octave_idx_type dim2 (void) const | 51 octave_idx_type dim2 (void) const |
52 { return Array<octave_idx_type>::length (); } | 52 { return Array<octave_idx_type>::length (); } |
53 | 53 |
54 octave_idx_type rows (void) const { return dim1 (); } | 54 octave_idx_type rows (void) const { return dim1 (); } |
55 octave_idx_type cols (void) const { return dim2 (); } | 55 octave_idx_type cols (void) const { return dim2 (); } |
56 octave_idx_type columns (void) const { return dim2 (); } | 56 octave_idx_type columns (void) const { return dim2 (); } |
57 | 57 |
58 octave_idx_type perm_length (void) const | 58 octave_idx_type perm_length (void) const |
59 { return Array<octave_idx_type>::length (); } | 59 { return Array<octave_idx_type>::length (); } |
60 // FIXME: a dangerous ambiguity? | 60 // FIXME: a dangerous ambiguity? |
61 octave_idx_type length (void) const | 61 octave_idx_type length (void) const |
62 { return perm_length (); } | 62 { return perm_length (); } |
63 octave_idx_type nelem (void) const { return dim1 () * dim2 (); } | 63 octave_idx_type nelem (void) const { return dim1 () * dim2 (); } |
64 octave_idx_type numel (void) const { return nelem (); } | 64 octave_idx_type numel (void) const { return nelem (); } |
65 | 65 |
66 size_t byte_size (void) const | 66 size_t byte_size (void) const |
67 { return Array<octave_idx_type>::byte_size (); } | 67 { return Array<octave_idx_type>::byte_size (); } |
68 | 68 |
69 dim_vector dims (void) const { return dim_vector (dim1 (), dim2 ()); } | 69 dim_vector dims (void) const { return dim_vector (dim1 (), dim2 ()); } |
70 | 70 |
71 Array<octave_idx_type> pvec (void) const | 71 Array<octave_idx_type> pvec (void) const |
72 { return *this; } | 72 { return *this; } |
73 | 73 |
74 octave_idx_type | 74 octave_idx_type |
75 elem (octave_idx_type i, octave_idx_type j) const | 75 elem (octave_idx_type i, octave_idx_type j) const |
76 { | 76 { |
77 return (_colp | 77 return (_colp |
78 ? ((Array<octave_idx_type>::elem (j) == i) ? 1 : 0) | 78 ? ((Array<octave_idx_type>::elem (j) == i) ? 1 : 0) |
79 : ((Array<octave_idx_type>::elem (i) == j) ? 1 : 0)); | 79 : ((Array<octave_idx_type>::elem (i) == j) ? 1 : 0)); |
80 } | 80 } |
81 | 81 |
82 octave_idx_type | 82 octave_idx_type |
83 checkelem (octave_idx_type i, octave_idx_type j) const; | 83 checkelem (octave_idx_type i, octave_idx_type j) const; |
84 | 84 |
85 octave_idx_type | 85 octave_idx_type |
86 operator () (octave_idx_type i, octave_idx_type j) const | 86 operator () (octave_idx_type i, octave_idx_type j) const |
87 { | 87 { |
89 return checkelem (i, j); | 89 return checkelem (i, j); |
90 #else | 90 #else |
91 return elem (i, j); | 91 return elem (i, j); |
92 #endif | 92 #endif |
93 } | 93 } |
94 | 94 |
95 // These are, in fact, super-fast. | 95 // These are, in fact, super-fast. |
96 PermMatrix transpose (void) const; | 96 PermMatrix transpose (void) const; |
97 PermMatrix inverse (void) const; | 97 PermMatrix inverse (void) const; |
98 | 98 |
99 // Determinant, i.e. the sign of permutation. | 99 // Determinant, i.e. the sign of permutation. |
105 bool is_col_perm (void) const { return _colp; } | 105 bool is_col_perm (void) const { return _colp; } |
106 bool is_row_perm (void) const { return !_colp; } | 106 bool is_row_perm (void) const { return !_colp; } |
107 | 107 |
108 friend OCTAVE_API PermMatrix operator *(const PermMatrix& a, const PermMatrix& b); | 108 friend OCTAVE_API PermMatrix operator *(const PermMatrix& a, const PermMatrix& b); |
109 | 109 |
110 const octave_idx_type *data (void) const | 110 const octave_idx_type *data (void) const |
111 { return Array<octave_idx_type>::data (); } | 111 { return Array<octave_idx_type>::data (); } |
112 | 112 |
113 const octave_idx_type *fortran_vec (void) const | 113 const octave_idx_type *fortran_vec (void) const |
114 { return Array<octave_idx_type>::fortran_vec (); } | 114 { return Array<octave_idx_type>::fortran_vec (); } |
115 | 115 |
116 octave_idx_type *fortran_vec (void) | 116 octave_idx_type *fortran_vec (void) |
117 { return Array<octave_idx_type>::fortran_vec (); } | 117 { return Array<octave_idx_type>::fortran_vec (); } |
118 | 118 |
119 void print_info (std::ostream& os, const std::string& prefix) const | 119 void print_info (std::ostream& os, const std::string& prefix) const |
120 { Array<octave_idx_type>::print_info (os, prefix); } | 120 { Array<octave_idx_type>::print_info (os, prefix); } |
121 | 121 |
124 private: | 124 private: |
125 bool _colp; | 125 bool _colp; |
126 }; | 126 }; |
127 | 127 |
128 // Multiplying permutations together. | 128 // Multiplying permutations together. |
129 PermMatrix | 129 PermMatrix |
130 OCTAVE_API | 130 OCTAVE_API |
131 operator *(const PermMatrix& a, const PermMatrix& b); | 131 operator *(const PermMatrix& a, const PermMatrix& b); |
132 | 132 |
133 #endif | 133 #endif |