annotate liboctave/util/lo-utils.h @ 27923:bd51beb6205e

update formatting of copyright notices * Use <https://octave.org/copyright/> instead of <https://octave.org/COPYRIGHT.html/>. * For consistency with other comments in the Octave sources, use C++-style comments for copyright blocks in C and C++ files. * Use delimiters above and below copyright blocks that are appropriate for the language used in the file. * Eliminate extra spacing inside copyright blocks. * lex.ll (looks_like_copyright): Also allow newlines and carriage returns before the word "Copyright". * scripts/mk-doc.pl (gethelp): Also skip empty comment lines. * bp-table.cc, type.m: Adjust tests.
author John W. Eaton <jwe@octave.org>
date Wed, 08 Jan 2020 11:59:41 -0500
parents 1891570abac8
children 83172e1c77f2 0a5b15007766
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 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 1996-2020 The Octave Project Developers
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 ////////////////////////////////////////////////////////////////////////
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_lo_utils_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17744
diff changeset
27 #define octave_lo_utils_h 1
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
30
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
31 #include <cstdio>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
32
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
33 #include <iosfwd>
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
34 #include <string>
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
35
11512
e4e82740e9cd prototype fixes for C language files
John W. Eaton <jwe@octave.org>
parents: 11211
diff changeset
36 #include "lo-cutils.h"
4130
7d9bda865012 [project @ 2002-10-28 21:05:30 by jwe]
jwe
parents: 3970
diff changeset
37 #include "oct-cmplx.h"
23443
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23220
diff changeset
38 #include "quit.h"
4130
7d9bda865012 [project @ 2002-10-28 21:05:30 by jwe]
jwe
parents: 3970
diff changeset
39
15212
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
40 // Generic any/all test functionality with arbitrary predicate.
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
41
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
42 template <typename F, typename T, bool zero>
15212
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
43 bool
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
44 any_all_test (F fcn, const T *m, octave_idx_type len)
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
45 {
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
46 octave_idx_type i;
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
47
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
48 for (i = 0; i < len - 3; i += 4)
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
49 {
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
50 octave_quit ();
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
51
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
52 if (fcn (m[i]) != zero
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
53 || fcn (m[i+1]) != zero
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
54 || fcn (m[i+2]) != zero
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
55 || fcn (m[i+3]) != zero)
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
56 return ! zero;
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
57 }
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
58
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
59 octave_quit ();
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
60
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
61 for (; i < len; i++)
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
62 if (fcn (m[i]) != zero)
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
63 return ! zero;
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
64
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
65 return zero;
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
66 }
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
67
11010
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
68 extern OCTAVE_API bool xis_int_or_inf_or_nan (double x);
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
69 extern OCTAVE_API bool xis_one_or_zero (double x);
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
70 extern OCTAVE_API bool xis_zero (double x);
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
71 extern OCTAVE_API bool xtoo_large_for_float (double x);
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
72
15212
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
73 extern OCTAVE_API bool xtoo_large_for_float (const Complex& x);
4bbd3bbb8912 reduce code duplication in too_large_for_float array functions
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
74
11010
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
75 extern OCTAVE_API bool xis_int_or_inf_or_nan (float x);
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
76 extern OCTAVE_API bool xis_one_or_zero (float x);
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
77 extern OCTAVE_API bool xis_zero (float x);
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
78 extern OCTAVE_API bool xtoo_large_for_float (float x);
9478b216752e simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents: 11006
diff changeset
79
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23443
diff changeset
80 extern OCTAVE_API char * strsave (const char *);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
81
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5453
diff changeset
82 extern OCTAVE_API std::string octave_fgets (std::FILE *);
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5453
diff changeset
83 extern OCTAVE_API std::string octave_fgetl (std::FILE *);
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
84
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5453
diff changeset
85 extern OCTAVE_API std::string octave_fgets (std::FILE *, bool& eof);
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5453
diff changeset
86 extern OCTAVE_API std::string octave_fgetl (std::FILE *, bool& eof);
3970
4f884e25aab9 [project @ 2002-07-02 04:14:35 by jwe]
jwe
parents: 3803
diff changeset
87
9469
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
88 template <typename T>
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
89 T
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
90 octave_read_value (std::istream& is)
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
91 {
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
92 T retval;
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
93 is >> retval;
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
94 return retval;
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
95 }
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
96
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
97 template <> OCTAVE_API double octave_read_value (std::istream& is);
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
98 template <> OCTAVE_API Complex octave_read_value (std::istream& is);
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
99 template <> OCTAVE_API float octave_read_value (std::istream& is);
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
100 template <> OCTAVE_API FloatComplex octave_read_value (std::istream& is);
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
101
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
102 // The next four functions are provided for backward compatibility.
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
103 inline double
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
104 octave_read_double (std::istream& is)
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
105 {
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
106 return octave_read_value<double> (is);
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
107 }
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
108
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
109 inline Complex
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
110 octave_read_complex (std::istream& is)
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
111 {
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
112 return octave_read_value<Complex> (is);
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
113 }
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
114
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
115 inline float
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
116 octave_read_float (std::istream& is)
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
117 {
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
118 return octave_read_value<float> (is);
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
119 }
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
120
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
121 inline FloatComplex
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
122 octave_read_float_complex (std::istream& is)
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
123 {
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
124 return octave_read_value<FloatComplex> (is);
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
125 }
4130
7d9bda865012 [project @ 2002-10-28 21:05:30 by jwe]
jwe
parents: 3970
diff changeset
126
10180
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
127 extern OCTAVE_API void
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
128 octave_write_double (std::ostream& os, double dval);
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
129
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
130 extern OCTAVE_API void
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
131 octave_write_complex (std::ostream& os, const Complex& cval);
4130
7d9bda865012 [project @ 2002-10-28 21:05:30 by jwe]
jwe
parents: 3970
diff changeset
132
10180
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
133 extern OCTAVE_API void
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
134 octave_write_float (std::ostream& os, float dval);
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
135
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
136 extern OCTAVE_API void
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
137 octave_write_float_complex (std::ostream& os, const FloatComplex& cval);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
138
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
139 #endif