Mercurial > octave
annotate libinterp/corefcn/ls-utils.cc @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
4634 | 1 /* |
2 | |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 Copyright (C) 2003-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
5 See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
6 or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
7 |
4634 | 8 |
9 This file is part of Octave. | |
10 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
11 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
13 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 (at your option) any later version. |
4634 | 15 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
17 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
19 GNU General Public License for more details. |
4634 | 20 |
21 You should have received a copy of the GNU General Public License | |
7016 | 22 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
23 <https://www.gnu.org/licenses/>. |
4634 | 24 |
25 */ | |
26 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
27 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
28 # include "config.h" |
4634 | 29 #endif |
30 | |
31 #include "data-conv.h" | |
32 | |
33 #include "ls-utils.h" | |
34 | |
35 // MAX_VAL and MIN_VAL are assumed to have integral values even though | |
36 // they are stored in doubles. | |
37 | |
38 save_type | |
4661 | 39 get_save_type (double /* max_val */, double /* min_val */) |
4634 | 40 { |
41 save_type st = LS_DOUBLE; | |
42 | |
43 // Matlab doesn't seem to load the UINT32 type correctly, so let's | |
44 // avoid it (and the other unsigned types, even though they may not | |
45 // have the same problem. And apparently, there are problems with | |
46 // other smaller types as well. If we avoid them all, then maybe we | |
47 // will avoid problems. Unfortunately, we won't be able to save | |
48 // space... | |
49 | |
50 // if (max_val < 256 && min_val > -1) | |
51 // st = LS_U_CHAR; | |
52 // else if (max_val < 65536 && min_val > -1) | |
53 // st = LS_U_SHORT; | |
54 // else if (max_val < 4294967295UL && min_val > -1) | |
55 // st = LS_U_INT; | |
56 // else if (max_val < 128 && min_val >= -128) | |
57 // st = LS_CHAR; | |
58 // else if (max_val < 32768 && min_val >= -32768) | |
59 // st = LS_SHORT; | |
60 // else if (max_val <= 2147483647L && min_val >= -2147483647L) | |
61 // st = LS_INT; | |
62 | |
63 return st; | |
64 } | |
11468
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
65 |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
66 save_type |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
67 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
|
68 { |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
69 save_type st = LS_FLOAT; |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
70 |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
71 // 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
|
72 // 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
|
73 // 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
|
74 // 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
|
75 // 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
|
76 // space... |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
77 |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
78 // if (max_val < 256 && min_val > -1) |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
79 // st = LS_U_CHAR; |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
80 // 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
|
81 // st = LS_U_SHORT; |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
82 // 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
|
83 // st = LS_U_INT; |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
84 // 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
|
85 // st = LS_CHAR; |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
86 // 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
|
87 // st = LS_SHORT; |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
88 // 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
|
89 // st = LS_INT; |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
90 |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
91 return st; |
e1edf0ba3bcb
Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents:
10160
diff
changeset
|
92 } |