annotate liboctave/array/dNDArray.cc @ 29937:da7210e30f3e

move some utility functions inside octave namespace * lo-utils.h, lo-utils.cc (is_one_or_zero): Rename from xis_one_or_zero and move inside octave namespace. Change all uses. (is_zero): Rename from xis_zero and move inside octave namespace. Change all uses. (is_int_or_inf_or_nan): Rename from xis_int_or_inf_or_nan and move inside octave namespace. Change all uses. (too_large_for_float): Rename from xtoo_large_for_float and move inside octave namespace. Change all uses. (too_large_for_float): Rename from xtoo_large_for_float and move inside octave namespace. Change all uses. (is_int_or_inf_or_nan): Rename from xis_int_or_inf_or_nan and move inside octave namespace. Change all uses. (fgets): Rename from octave_fgets and move inside octave namespace. Change all uses. (fgetl): Rename from octave_fgetl and move inside octave namespace. Change all uses. (any_all_test, strsave): Move inside octave namespace. Tag uses with octave:: prefix as needed. * lo-utils.h: Provide deprecated templates and inline functions to preserve old names in global namespace.
author John W. Eaton <jwe@octave.org>
date Tue, 03 Aug 2021 12:34:52 -0400
parents 7faff48840eb
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 1996-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
4511
24af46b4ce84 [project @ 2003-09-12 16:46:04 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
27 # include "config.h"
4511
24af46b4ce84 [project @ 2003-09-12 16:46:04 by jwe]
jwe
parents:
diff changeset
28 #endif
24af46b4ce84 [project @ 2003-09-12 16:46:04 by jwe]
jwe
parents:
diff changeset
29
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
30 #include <istream>
23443
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23220
diff changeset
31 #include <limits>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
32 #include <ostream>
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
33
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents: 4584
diff changeset
34 #include "Array-util.h"
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
35 #include "dNDArray.h"
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
36 #include "f77-fcn.h"
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
37 #include "lo-error.h"
4511
24af46b4ce84 [project @ 2003-09-12 16:46:04 by jwe]
jwe
parents:
diff changeset
38 #include "lo-ieee.h"
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
39 #include "lo-mappers.h"
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
40 #include "mx-base.h"
8774
b756ce0002db split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents: 8751
diff changeset
41 #include "mx-op-defs.h"
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
42 #include "oct-fftw.h"
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
43 #include "oct-locbuf.h"
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
44
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
45 #include "bsxfun-defs.cc"
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
46
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
47 NDArray::NDArray (const Array<octave_idx_type>& a, bool zero_based,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
48 bool negative_to_nan)
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
49 {
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
50 const octave_idx_type *pa = a.data ();
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
51 resize (a.dims ());
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
52 double *ptmp = fortran_vec ();
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
53 if (negative_to_nan)
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
54 {
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
55 double nan_val = lo_ieee_nan_value ();
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
56
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
57 if (zero_based)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
58 for (octave_idx_type i = 0; i < a.numel (); i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
59 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
60 double val = static_cast<double>
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
61 (pa[i] + static_cast<octave_idx_type> (1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
62 if (val <= 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
63 ptmp[i] = nan_val;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
64 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
65 ptmp[i] = val;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
66 }
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
67 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
68 for (octave_idx_type i = 0; i < a.numel (); i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
69 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
70 double val = static_cast<double> (pa[i]);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
71 if (val <= 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
72 ptmp[i] = nan_val;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
73 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
74 ptmp[i] = val;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
75 }
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
76 }
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
77 else
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
78 {
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
79 if (zero_based)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
80 for (octave_idx_type i = 0; i < a.numel (); i++)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
81 ptmp[i] = static_cast<double>
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
82 (pa[i] + static_cast<octave_idx_type> (1));
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
83 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
84 for (octave_idx_type i = 0; i < a.numel (); i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
85 ptmp[i] = static_cast<double> (pa[i]);
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
86 }
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
87 }
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
88
8956
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
89 NDArray::NDArray (const charNDArray& a)
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10329
diff changeset
90 : MArray<double> (a.dims ())
8956
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
91 {
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
92 octave_idx_type n = a.numel ();
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
93 for (octave_idx_type i = 0; i < n; i++)
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
94 xelem (i) = static_cast<unsigned char> (a(i));
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
95 }
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
96
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
97 #if defined (HAVE_FFTW)
7941
f8cab9eeb128 Fix NDArray compilation/export
John W. Eaton <jwe@octave.org>
parents: 7922
diff changeset
98
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
99 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
100 NDArray::fourier (int dim) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
101 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
102 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
103
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21562
diff changeset
104 if (dim > dv.ndims () || dim < 0)
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
105 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
106
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
107 octave_idx_type stride = 1;
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
108 octave_idx_type n = dv(dim);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
109
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
110 for (int i = 0; i < dim; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
111 stride *= dv(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
112
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19697
diff changeset
113 octave_idx_type howmany = numel () / dv(dim);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
114 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19697
diff changeset
115 octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
116 octave_idx_type dist = (stride == 1 ? n : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
117
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
118 const double *in (data ());
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
119 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
120 Complex *out (retval.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
121
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
122 // Need to be careful here about the distance between fft's
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
123 for (octave_idx_type k = 0; k < nloop; k++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
124 octave::fftw::fft (in + k * stride * n, out + k * stride * n,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
125 n, howmany, stride, dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
126
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
127 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
128 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
129
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
130 ComplexNDArray
4816
4908c82cd1a1 [project @ 2004-03-04 18:13:46 by jwe]
jwe
parents: 4806
diff changeset
131 NDArray::ifourier (int dim) const
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
132 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
133 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
134
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21562
diff changeset
135 if (dim > dv.ndims () || dim < 0)
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
136 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
137
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
138 octave_idx_type stride = 1;
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
139 octave_idx_type n = dv(dim);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
140
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
141 for (int i = 0; i < dim; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
142 stride *= dv(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
143
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19697
diff changeset
144 octave_idx_type howmany = numel () / dv(dim);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
145 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19697
diff changeset
146 octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
147 octave_idx_type dist = (stride == 1 ? n : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
148
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
149 ComplexNDArray retval (*this);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
150 Complex *out (retval.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
151
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
152 // Need to be careful here about the distance between fft's
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
153 for (octave_idx_type k = 0; k < nloop; k++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
154 octave::fftw::ifft (out + k * stride * n, out + k * stride * n,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
155 n, howmany, stride, dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
156
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
157 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
158 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
159
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
160 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
161 NDArray::fourier2d (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
162 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
163 dim_vector dv = dims ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21562
diff changeset
164 if (dv.ndims () < 2)
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
165 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
166
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19697
diff changeset
167 dim_vector dv2 (dv(0), dv(1));
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
168 const double *in = data ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
169 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
170 Complex *out = retval.fortran_vec ();
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
171 octave_idx_type howmany = numel () / dv(0) / dv(1);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
172 octave_idx_type dist = dv(0) * dv(1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
173
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
174 for (octave_idx_type i=0; i < howmany; i++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
175 octave::fftw::fftNd (in + i*dist, out + i*dist, 2, dv2);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
176
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
177 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
178 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
179
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
180 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
181 NDArray::ifourier2d (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
182 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
183 dim_vector dv = dims ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21562
diff changeset
184 if (dv.ndims () < 2)
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
185 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
186
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19697
diff changeset
187 dim_vector dv2 (dv(0), dv(1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
188 ComplexNDArray retval (*this);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
189 Complex *out = retval.fortran_vec ();
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14844
diff changeset
190 octave_idx_type howmany = numel () / dv(0) / dv(1);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
191 octave_idx_type dist = dv(0) * dv(1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
192
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
193 for (octave_idx_type i=0; i < howmany; i++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
194 octave::fftw::ifftNd (out + i*dist, out + i*dist, 2, dv2);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
195
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
196 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
197 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
198
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
199 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
200 NDArray::fourierNd (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
201 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
202 dim_vector dv = dims ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21562
diff changeset
203 int rank = dv.ndims ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
204
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
205 const double *in (data ());
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
206 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
207 Complex *out (retval.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
208
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
209 octave::fftw::fftNd (in, out, rank, dv);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
210
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
211 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
212 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
213
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
214 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
215 NDArray::ifourierNd (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
216 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
217 dim_vector dv = dims ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21562
diff changeset
218 int rank = dv.ndims ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
219
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
220 ComplexNDArray tmp (*this);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
221 Complex *in (tmp.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
222 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
223 Complex *out (retval.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
224
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
225 octave::fftw::ifftNd (in, out, rank, dv);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
226
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
227 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
228 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
229
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
230 #else
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
231
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
232 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
233 NDArray::fourier (int dim) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
234 {
26516
53d03e2e4948 silence unused parameter compiler warnings when building without FFTW
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
235 octave_unused_parameter (dim);
53d03e2e4948 silence unused parameter compiler warnings when building without FFTW
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
236
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
237 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
238 ("support for FFTW was unavailable or disabled when liboctave was built");
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
239
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
240 return ComplexNDArray ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
241 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
242
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
243 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
244 NDArray::ifourier (int dim) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
245 {
26516
53d03e2e4948 silence unused parameter compiler warnings when building without FFTW
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
246 octave_unused_parameter (dim);
53d03e2e4948 silence unused parameter compiler warnings when building without FFTW
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
247
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
248 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
249 ("support for FFTW was unavailable or disabled when liboctave was built");
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
250
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
251 return ComplexNDArray ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
252 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
253
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
254 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
255 NDArray::fourier2d (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
256 {
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
257 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
258 ("support for FFTW was unavailable or disabled when liboctave was built");
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
259
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
260 return ComplexNDArray ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
261 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
262
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
263 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
264 NDArray::ifourier2d (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
265 {
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
266 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
267 ("support for FFTW was unavailable or disabled when liboctave was built");
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
268
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
269 return ComplexNDArray ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
270 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
271
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
272 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
273 NDArray::fourierNd (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
274 {
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
275 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
276 ("support for FFTW was unavailable or disabled when liboctave was built");
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
277
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
278 return ComplexNDArray ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
279 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
280
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
281 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
282 NDArray::ifourierNd (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
283 {
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
284 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
285 ("support for FFTW was unavailable or disabled when liboctave was built");
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
286
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
287 return ComplexNDArray ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
288 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
289
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
290 #endif
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
291
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
292 // unary operations
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
293
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
294 boolNDArray
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
295 NDArray::operator ! (void) const
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
296 {
11130
7c573eb981eb consistently give error for operator not applied to NaN values
John W. Eaton <jwe@octave.org>
parents: 11010
diff changeset
297 if (any_element_is_nan ())
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
298 octave::err_nan_to_logical_conversion ();
11130
7c573eb981eb consistently give error for operator not applied to NaN values
John W. Eaton <jwe@octave.org>
parents: 11010
diff changeset
299
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
300 return do_mx_unary_op<bool, double> (*this, mx_inline_not);
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
301 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
302
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
303 bool
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
304 NDArray::any_element_is_negative (bool neg_zero) const
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
305 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
306 return (neg_zero ? test_all (octave::math::negative_sign)
11010
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11008
diff changeset
307 : do_mx_check<double> (*this, mx_inline_any_negative));
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
308 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
309
7922
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7919
diff changeset
310 bool
13756
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13005
diff changeset
311 NDArray::any_element_is_positive (bool neg_zero) const
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13005
diff changeset
312 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
313 return (neg_zero ? test_all (octave::math::positive_sign)
13756
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13005
diff changeset
314 : do_mx_check<double> (*this, mx_inline_any_positive));
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13005
diff changeset
315 }
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13005
diff changeset
316
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13005
diff changeset
317 bool
7922
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7919
diff changeset
318 NDArray::any_element_is_nan (void) const
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7919
diff changeset
319 {
11008
3622db30ff05 simplify some array tests in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10362
diff changeset
320 return do_mx_check<double> (*this, mx_inline_any_nan);
7922
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7919
diff changeset
321 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
322
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
323 bool
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
324 NDArray::any_element_is_inf_or_nan (void) const
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
325 {
11008
3622db30ff05 simplify some array tests in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10362
diff changeset
326 return ! do_mx_check<double> (*this, mx_inline_all_finite);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
327 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
328
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
329 bool
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5775
diff changeset
330 NDArray::any_element_not_one_or_zero (void) const
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5775
diff changeset
331 {
29937
da7210e30f3e move some utility functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29931
diff changeset
332 return ! test_all (octave::is_one_or_zero);
5943
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5775
diff changeset
333 }
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5775
diff changeset
334
c038c2947ee1 [project @ 2006-08-18 21:27:03 by jwe]
jwe
parents: 5775
diff changeset
335 bool
6989
2d326000e09b [project @ 2007-10-09 20:32:42 by jwe]
jwe
parents: 5943
diff changeset
336 NDArray::all_elements_are_zero (void) const
2d326000e09b [project @ 2007-10-09 20:32:42 by jwe]
jwe
parents: 5943
diff changeset
337 {
29937
da7210e30f3e move some utility functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29931
diff changeset
338 return test_all (octave::is_zero);
6989
2d326000e09b [project @ 2007-10-09 20:32:42 by jwe]
jwe
parents: 5943
diff changeset
339 }
2d326000e09b [project @ 2007-10-09 20:32:42 by jwe]
jwe
parents: 5943
diff changeset
340
2d326000e09b [project @ 2007-10-09 20:32:42 by jwe]
jwe
parents: 5943
diff changeset
341 bool
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
342 NDArray::all_elements_are_int_or_inf_or_nan (void) const
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
343 {
29937
da7210e30f3e move some utility functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29931
diff changeset
344 return test_all (octave::is_int_or_inf_or_nan);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
345 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
346
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
347 // Return nonzero if any element of M is not an integer. Also extract
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
348 // the largest and smallest values and return them in MAX_VAL and MIN_VAL.
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
349
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
350 bool
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
351 NDArray::all_integers (double& max_val, double& min_val) const
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
352 {
20228
00cf2847355d Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
353 octave_idx_type nel = numel ();
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
354
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
355 if (nel > 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
356 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
357 max_val = elem (0);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
358 min_val = elem (0);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
359 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
360 else
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
361 return false;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
362
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
363 for (octave_idx_type i = 0; i < nel; i++)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
364 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
365 double val = elem (i);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
366
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
367 if (val > max_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
368 max_val = val;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
369
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
370 if (val < min_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
371 min_val = val;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
372
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
373 if (! octave::math::isinteger (val))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
374 return false;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
375 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
376
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
377 return true;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
378 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
379
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
380 bool
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
381 NDArray::all_integers (void) const
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
382 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
383 return test_all (octave::math::isinteger);
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
384 }
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
385
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
386 bool
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
387 NDArray::too_large_for_float (void) const
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
388 {
29937
da7210e30f3e move some utility functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29931
diff changeset
389 return test_any (octave::too_large_for_float);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
390 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
391
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
392 // FIXME: this is not quite the right thing.
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
393
4556
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
394 boolNDArray
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
395 NDArray::all (int dim) const
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
396 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
397 return do_mx_red_op<bool, double> (*this, dim, mx_inline_all);
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
398 }
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
399
4556
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
400 boolNDArray
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
401 NDArray::any (int dim) const
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
402 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
403 return do_mx_red_op<bool, double> (*this, dim, mx_inline_any);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
404 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
405
4584
f7697d703481 [project @ 2003-10-31 19:47:35 by jwe]
jwe
parents: 4569
diff changeset
406 NDArray
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
407 NDArray::cumprod (int dim) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
408 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
409 return do_mx_cum_op<double, double> (*this, dim, mx_inline_cumprod);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
410 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
411
4584
f7697d703481 [project @ 2003-10-31 19:47:35 by jwe]
jwe
parents: 4569
diff changeset
412 NDArray
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
413 NDArray::cumsum (int dim) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
414 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
415 return do_mx_cum_op<double, double> (*this, dim, mx_inline_cumsum);
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
416 }
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4511
diff changeset
417
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
418 NDArray
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
419 NDArray::prod (int dim) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
420 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
421 return do_mx_red_op<double, double> (*this, dim, mx_inline_prod);
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
422 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
423
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
424 NDArray
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
425 NDArray::sum (int dim) const
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
426 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
427 return do_mx_red_op<double, double> (*this, dim, mx_inline_sum);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
428 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
429
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
430 NDArray
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
431 NDArray::xsum (int dim) const
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
432 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
433 return do_mx_red_op<double, double> (*this, dim, mx_inline_xsum);
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
434 }
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
435
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
436 NDArray
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
437 NDArray::sumsq (int dim) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
438 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
439 return do_mx_red_op<double, double> (*this, dim, mx_inline_sumsq);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
440 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
441
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
442 NDArray
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
443 NDArray::max (int dim) const
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
444 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
445 return do_mx_minmax_op<double> (*this, dim, mx_inline_max);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
446 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
447
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
448 NDArray
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
449 NDArray::max (Array<octave_idx_type>& idx_arg, int dim) const
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
450 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
451 return do_mx_minmax_op<double> (*this, idx_arg, dim, mx_inline_max);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
452 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
453
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
454 NDArray
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
455 NDArray::min (int dim) const
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
456 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
457 return do_mx_minmax_op<double> (*this, dim, mx_inline_min);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
458 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
459
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
460 NDArray
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
461 NDArray::min (Array<octave_idx_type>& idx_arg, int dim) const
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
462 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
463 return do_mx_minmax_op<double> (*this, idx_arg, dim, mx_inline_min);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
464 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
465
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
466 NDArray
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
467 NDArray::cummax (int dim) const
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
468 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
469 return do_mx_cumminmax_op<double> (*this, dim, mx_inline_cummax);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
470 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
471
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
472 NDArray
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
473 NDArray::cummax (Array<octave_idx_type>& idx_arg, int dim) const
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
474 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
475 return do_mx_cumminmax_op<double> (*this, idx_arg, dim, mx_inline_cummax);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
476 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
477
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
478 NDArray
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
479 NDArray::cummin (int dim) const
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
480 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
481 return do_mx_cumminmax_op<double> (*this, dim, mx_inline_cummin);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
482 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
483
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
484 NDArray
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
485 NDArray::cummin (Array<octave_idx_type>& idx_arg, int dim) const
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
486 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
487 return do_mx_cumminmax_op<double> (*this, idx_arg, dim, mx_inline_cummin);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
488 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
489
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
490 NDArray
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
491 NDArray::diff (octave_idx_type order, int dim) const
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
492 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
493 return do_mx_diff_op<double> (*this, dim, order, mx_inline_diff);
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
494 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
495
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
496 NDArray
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
497 NDArray::concat (const NDArray& rb, const Array<octave_idx_type>& ra_idx)
4758
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4687
diff changeset
498 {
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
499 if (rb.numel () > 0)
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
500 insert (rb, ra_idx);
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
501 return *this;
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
502 }
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
503
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
504 ComplexNDArray
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
505 NDArray::concat (const ComplexNDArray& rb, const Array<octave_idx_type>& ra_idx)
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
506 {
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
507 ComplexNDArray retval (*this);
4940
954cc2ba6a49 [project @ 2004-08-24 19:30:31 by jwe]
jwe
parents: 4915
diff changeset
508 if (rb.numel () > 0)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
509 retval.insert (rb, ra_idx);
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
510 return retval;
4758
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4687
diff changeset
511 }
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4687
diff changeset
512
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
513 charNDArray
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
514 NDArray::concat (const charNDArray& rb, const Array<octave_idx_type>& ra_idx)
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
515 {
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
516 charNDArray retval (dims ());
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
517 octave_idx_type nel = numel ();
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
518
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
519 for (octave_idx_type i = 0; i < nel; i++)
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
520 {
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
521 double d = elem (i);
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
522
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
523 if (octave::math::isnan (d))
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21100
diff changeset
524 (*current_liboctave_error_handler)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21100
diff changeset
525 ("invalid conversion from NaN to character");
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21100
diff changeset
526
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
527 octave_idx_type ival = octave::math::nint_big (d);
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
528
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21100
diff changeset
529 if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21100
diff changeset
530 // FIXME: is there something better to do? Should we warn the user?
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21100
diff changeset
531 ival = 0;
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
532
25688
b2917b7858ba maint: Use Octave convention for spacing of C++ cast statements.
Rik <rik@octave.org>
parents: 25586
diff changeset
533 retval.elem (i) = static_cast<char> (ival);
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
534 }
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
535
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23564
diff changeset
536 if (rb.isempty ())
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
537 return retval;
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
538
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
539 retval.insert (rb, ra_idx);
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
540 return retval;
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
541 }
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
542
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
543 NDArray
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
544 real (const ComplexNDArray& a)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
545 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
546 return do_mx_unary_op<double, Complex> (a, mx_inline_real);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
547 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
548
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
549 NDArray
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
550 imag (const ComplexNDArray& a)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
551 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
552 return do_mx_unary_op<double, Complex> (a, mx_inline_imag);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
553 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
554
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
555 NDArray&
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
556 NDArray::insert (const NDArray& a, octave_idx_type r, octave_idx_type c)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
557 {
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
558 Array<double>::insert (a, r, c);
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
559 return *this;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
560 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
561
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
562 NDArray&
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
563 NDArray::insert (const NDArray& a, const Array<octave_idx_type>& ra_idx)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
564 {
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
565 Array<double>::insert (a, ra_idx);
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
566 return *this;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
567 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
568
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
569 NDArray
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
570 NDArray::abs (void) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
571 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
572 return do_mx_unary_map<double, double, std::abs> (*this);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
573 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
574
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
575 boolNDArray
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
576 NDArray::isnan (void) const
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
577 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
578 return do_mx_unary_map<bool, double, octave::math::isnan> (*this);
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
579 }
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
580
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
581 boolNDArray
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
582 NDArray::isinf (void) const
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
583 {
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
584 return do_mx_unary_map<bool, double, octave::math::isinf> (*this);
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
585 }
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
586
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
587 boolNDArray
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
588 NDArray::isfinite (void) const
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
589 {
23564
7049da1648c0 Deprecate octave::math::finite in favor of octave::math::isfinite.
Rik <rik@octave.org>
parents: 23461
diff changeset
590 return do_mx_unary_map<bool, double, octave::math::isfinite> (*this);
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
591 }
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
592
4532
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4513
diff changeset
593 void
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
594 NDArray::increment_index (Array<octave_idx_type>& ra_idx,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
595 const dim_vector& dimensions,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
596 int start_dimension)
4532
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4513
diff changeset
597 {
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4513
diff changeset
598 ::increment_index (ra_idx, dimensions, start_dimension);
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4513
diff changeset
599 }
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4513
diff changeset
600
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
601 octave_idx_type
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
602 NDArray::compute_index (Array<octave_idx_type>& ra_idx,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
603 const dim_vector& dimensions)
4556
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
604 {
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
605 return ::compute_index (ra_idx, dimensions);
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
606 }
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
607
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
608 NDArray
7620
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
609 NDArray::diag (octave_idx_type k) const
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
610 {
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10329
diff changeset
611 return MArray<double>::diag (k);
7620
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
612 }
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
613
14557
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
614 NDArray
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
615 NDArray::diag (octave_idx_type m, octave_idx_type n) const
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
616 {
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
617 return MArray<double>::diag (m, n);
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
618 }
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
619
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
620 // This contains no information on the array structure !!!
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
621 std::ostream&
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
622 operator << (std::ostream& os, const NDArray& a)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
623 {
20228
00cf2847355d Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
624 octave_idx_type nel = a.numel ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
625
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
626 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
627 {
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23577
diff changeset
628 os << ' ';
28628
83172e1c77f2 refactor octave_read_* and octave_write_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
629 octave::write_value<double> (os, a.elem (i));
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
630 os << "\n";
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
631 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
632 return os;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
633 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
634
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
635 std::istream&
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
636 operator >> (std::istream& is, NDArray& a)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
637 {
20228
00cf2847355d Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
638 octave_idx_type nel = a.numel ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
639
8999
dc07bc4157b8 allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents: 8998
diff changeset
640 if (nel > 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
641 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
642 double tmp;
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
643 for (octave_idx_type i = 0; i < nel; i++)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
644 {
28628
83172e1c77f2 refactor octave_read_* and octave_write_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
645 tmp = octave::read_value<double> (is);
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
646 if (is)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
647 a.elem (i) = tmp;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
648 else
21169
40051830f89b maint: Replace more instances of goto in liboctave with other constructs.
Rik <rik@octave.org>
parents: 21136
diff changeset
649 return is;
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
650 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
651 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
652
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
653 return is;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
654 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
655
10329
83fa590b8a09 simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
656 MINMAX_FCNS (NDArray, double)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
657
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
658 NDS_CMP_OPS (NDArray, double)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
659 NDS_BOOL_OPS (NDArray, double)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
660
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
661 SND_CMP_OPS (double, NDArray)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
662 SND_BOOL_OPS (double, NDArray)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
663
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
664 NDND_CMP_OPS (NDArray, NDArray)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
665 NDND_BOOL_OPS (NDArray, NDArray)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
666
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
667 BSXFUN_STDOP_DEFS_MXLOOP (NDArray)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
668 BSXFUN_STDREL_DEFS_MXLOOP (NDArray)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
669
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
670 BSXFUN_OP_DEF_MXLOOP (pow, NDArray, mx_inline_pow)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
671 BSXFUN_OP2_DEF_MXLOOP (pow, ComplexNDArray, ComplexNDArray,
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
672 NDArray, mx_inline_pow)
13005
4061106b1c4b Enable automatic bsxfun for power operators
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
673 BSXFUN_OP2_DEF_MXLOOP (pow, ComplexNDArray, NDArray,
4061106b1c4b Enable automatic bsxfun for power operators
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
674 ComplexNDArray, mx_inline_pow)