annotate liboctave/numeric/bsxfun.h @ 31249:de6fc38c78c6

Make Jacobian types offered by dlsode.f accessible by lsode (bug #31626). * liboctave/numeric/LSODE-opts.in: Add options "jacobian type", "lower jacobian subdiagonals", and "upper jacobian subdiagonals". * liboctave/numeric/LSODE.cc (file scope, lsode_j, LSODE::do_integrate (double)): Handle new configurable Jacobian types. * build-aux/mk-opts.pl: Don't implicitly convert to integer in condition.
author Olaf Till <olaf.till@uni-jena.de>
date Fri, 12 Nov 2010 08:53:05 +0100
parents 84fa12727b43
children 597f3ee61a48
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3 // Copyright (C) 2012-2022 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 ////////////////////////////////////////////////////////////////////////
16768
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19852
diff changeset
26 #if ! defined (octave_bsxfun_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17769
diff changeset
27 #define octave_bsxfun_h 1
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
30
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
31 #include <algorithm>
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23220
diff changeset
32 #include <string>
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
33
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
34 #include "dim-vector.h"
25038
63f17bf9932a maint: add missing includes for definitions used in public header files
Mike Miller <mtmiller@octave.org>
parents: 24947
diff changeset
35 #include "lo-error.h"
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
36
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
37 inline
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
38 bool
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
39 is_valid_bsxfun (const std::string& name,
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
40 const dim_vector& xdv, const dim_vector& ydv)
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
41 {
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
42 for (int i = 0; i < std::min (xdv.ndims (), ydv.ndims ()); i++)
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
43 {
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
44 octave_idx_type xk = xdv(i);
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
45 octave_idx_type yk = ydv(i);
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
46 // Check the three conditions for valid bsxfun dims
21345
12280fef2741 automatic broadcasting: correctly handle dimensions of length zero (bug #47085)
Carnë Draug <carandraug@octave.org>
parents: 21244
diff changeset
47 if (! ((xk == yk) || (xk == 1 && yk != 1) || (xk != 1 && yk == 1)))
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
48 return false;
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
49 }
14056
c3d401562410 allow warning (or error) for automatic bsxfun
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
50
c3d401562410 allow warning (or error) for automatic bsxfun
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
51 (*current_liboctave_warning_with_id_handler)
27216
823b4bcf79fc unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
52 ("Octave:language-extension", "performing '%s' automatic broadcasting",
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
53 name.c_str ());
14056
c3d401562410 allow warning (or error) for automatic bsxfun
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
54
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
55 return true;
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
56 }
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
57
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
58 // For inplace operations the size of the resulting matrix cannot be changed.
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
59 // Therefore we can only apply singleton expansion on the second matrix which
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
60 // alters the conditions to check.
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
61 inline
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
62 bool
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
63 is_valid_inplace_bsxfun (const std::string& name,
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
64 const dim_vector& rdv, const dim_vector& xdv)
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
65 {
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
66 octave_idx_type r_nd = rdv.ndims ();
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
67 octave_idx_type x_nd = xdv.ndims ();
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
68 if (r_nd < x_nd)
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
69 return false;
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
70
30917
84fa12727b43 Avoid out-of-bounds indexing when checking for broadcastable inplace operators (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
71 for (int i = 0; i < x_nd; i++)
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
72 {
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
73 octave_idx_type rk = rdv(i);
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
74 octave_idx_type xk = xdv(i);
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13006
diff changeset
75
24947
bff4a7c7bc39 Fix bsxfun when operating with float complex values (bug #53179).
Rik <rik@octave.org>
parents: 24534
diff changeset
76 // Only two valid conditions to check; can't stretch rk
30917
84fa12727b43 Avoid out-of-bounds indexing when checking for broadcastable inplace operators (bug #38466).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
77 if ((rk != xk) && xk != 1)
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
78 return false;
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
79 }
14056
c3d401562410 allow warning (or error) for automatic bsxfun
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
80
c3d401562410 allow warning (or error) for automatic bsxfun
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
81 (*current_liboctave_warning_with_id_handler)
27216
823b4bcf79fc unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
82 ("Octave:language-extension", "performing '%s' automatic broadcasting",
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
83 name.c_str ());
14056
c3d401562410 allow warning (or error) for automatic bsxfun
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
84
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
85 return true;
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
86 }
13005
4061106b1c4b Enable automatic bsxfun for power operators
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 13004
diff changeset
87
13006
61be447052c3 Implement automatic bsxfun almost everywhere now except sparse matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 13005
diff changeset
88 #include "bsxfun-defs.cc"
61be447052c3 Implement automatic bsxfun almost everywhere now except sparse matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 13005
diff changeset
89
13005
4061106b1c4b Enable automatic bsxfun for power operators
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 13004
diff changeset
90 #endif