annotate libinterp/corefcn/ls-utils.cc @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 75dff8f2de2e
children e88a07dec498
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: 30006
diff changeset
3 // Copyright (C) 2003-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 ////////////////////////////////////////////////////////////////////////
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
28 #endif
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
29
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
30 #include "data-conv.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
31
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
32 #include "ls-utils.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
33
30006
75dff8f2de2e move some load-save utilities to octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
34 OCTAVE_NAMESPACE_BEGIN
75dff8f2de2e move some load-save utilities to octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
35
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
36 // MAX_VAL and MIN_VAL are assumed to have integral values even though
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
37 // they are stored in doubles.
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
38
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
39 save_type
4661
12b6fbd57436 [project @ 2003-11-25 05:41:35 by jwe]
jwe
parents: 4634
diff changeset
40 get_save_type (double /* max_val */, double /* min_val */)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
41 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
42 save_type st = LS_DOUBLE;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
43
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
44 // Matlab doesn't seem to load the UINT32 type correctly, so let's
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
45 // avoid it (and the other unsigned types, even though they may not
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
46 // have the same problem. And apparently, there are problems with
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
47 // other smaller types as well. If we avoid them all, then maybe we
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
48 // will avoid problems. Unfortunately, we won't be able to save
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
49 // space...
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
50
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
51 // if (max_val < 256 && min_val > -1)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
52 // st = LS_U_CHAR;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
53 // else if (max_val < 65536 && min_val > -1)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
54 // st = LS_U_SHORT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
55 // else if (max_val < 4294967295UL && min_val > -1)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
56 // st = LS_U_INT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
57 // else if (max_val < 128 && min_val >= -128)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
58 // st = LS_CHAR;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
59 // else if (max_val < 32768 && min_val >= -32768)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
60 // st = LS_SHORT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
61 // else if (max_val <= 2147483647L && min_val >= -2147483647L)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
62 // st = LS_INT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
63
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
64 return st;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
65 }
11468
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
66
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
67 save_type
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
68 get_save_type (float /* max_val */, float /* min_val */)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
69 {
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
70 save_type st = LS_FLOAT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
71
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
72 // Matlab doesn't seem to load the UINT32 type correctly, so let's
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
73 // avoid it (and the other unsigned types, even though they may not
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
74 // have the same problem. And apparently, there are problems with
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
75 // other smaller types as well. If we avoid them all, then maybe we
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
76 // will avoid problems. Unfortunately, we won't be able to save
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
77 // space...
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
78
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
79 // if (max_val < 256 && min_val > -1)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
80 // st = LS_U_CHAR;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
81 // else if (max_val < 65536 && min_val > -1)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
82 // st = LS_U_SHORT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
83 // else if (max_val < 4294967295UL && min_val > -1)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
84 // st = LS_U_INT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
85 // else if (max_val < 128 && min_val >= -128)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
86 // st = LS_CHAR;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
87 // else if (max_val < 32768 && min_val >= -32768)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
88 // st = LS_SHORT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
89 // else if (max_val <= 2147483647L && min_val >= -2147483647L)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
90 // st = LS_INT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
91
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
92 return st;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
93 }
30006
75dff8f2de2e move some load-save utilities to octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
94
75dff8f2de2e move some load-save utilities to octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
95 OCTAVE_NAMESPACE_END
75dff8f2de2e move some load-save utilities to octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
96