Mercurial > hg > octave-lyh
comparison liboctave/CNDArray.cc @ 4634:79fe96966ca0
[project @ 2003-11-19 21:22:39 by jwe]
author | jwe |
---|---|
date | Wed, 19 Nov 2003 21:23:19 +0000 |
parents | 19bfd295f400 |
children | e95c86d48732 |
comparison
equal
deleted
inserted
replaced
4633:d95dd6ae89fd | 4634:79fe96966ca0 |
---|---|
118 ComplexNDArray::sum (int dim) const | 118 ComplexNDArray::sum (int dim) const |
119 { | 119 { |
120 MX_ND_COMPLEX_OP_REDUCTION (+= elem (iter_idx), Complex (0, 0)); | 120 MX_ND_COMPLEX_OP_REDUCTION (+= elem (iter_idx), Complex (0, 0)); |
121 } | 121 } |
122 | 122 |
123 Matrix | 123 NDArray |
124 ComplexNDArray::abs (void) const | 124 ComplexNDArray::abs (void) const |
125 { | 125 { |
126 Matrix retval; | 126 NDArray retval (dims ()); |
127 | 127 |
128 if (dims () . length () == 2) | 128 int nel = nelem (); |
129 { | |
130 int nr = rows (); | |
131 int nc = cols (); | |
132 | 129 |
133 retval.resize (nr, nc); | 130 for (int i = 0; i < nel; i++) |
134 | 131 retval(i) = ::abs (elem (i)); |
135 for (int j = 0; j < nc; j++) | |
136 for (int i = 0; i < nr; i++) | |
137 retval (i, j) = ::abs (elem (i, j)); | |
138 } | |
139 else | |
140 (*current_liboctave_error_handler) | |
141 ("abs is not yet implemented for N-d arrays"); | |
142 | 132 |
143 return retval; | 133 return retval; |
144 } | 134 } |
145 | 135 |
146 ComplexMatrix | 136 ComplexMatrix |