Mercurial > hg > octave-nkf
annotate liboctave/lo-utils.h @ 10509:ddbd812d09aa
properly compress sparse matrices after assembly
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 12 Apr 2010 12:57:44 +0200 |
parents | 65d5776379c3 |
children | aca961a3f387 |
rev | line source |
---|---|
1967 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008 John W. Eaton |
1967 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1967 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1967 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_liboctave_utils_h) | |
25 #define octave_liboctave_utils_h 1 | |
26 | |
2926 | 27 #include <cstdio> |
28 | |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
29 #include <iostream> |
2926 | 30 #include <string> |
31 | |
4130 | 32 #include "oct-cmplx.h" |
5453 | 33 #include "syswait.h" |
4130 | 34 |
6108 | 35 extern OCTAVE_API octave_idx_type NINTbig (double x); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
36 extern OCTAVE_API octave_idx_type NINTbig (float x); |
6108 | 37 extern OCTAVE_API int NINT (double x); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
38 extern OCTAVE_API int NINT (float x); |
6108 | 39 extern OCTAVE_API double D_NINT (double x); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
40 extern OCTAVE_API float F_NINT (float x); |
1967 | 41 |
6108 | 42 extern OCTAVE_API char *strsave (const char *); |
2926 | 43 |
10180 | 44 extern OCTAVE_API void |
45 octave_putenv (const std::string&, const std::string&); | |
2926 | 46 |
6108 | 47 extern OCTAVE_API std::string octave_fgets (std::FILE *); |
48 extern OCTAVE_API std::string octave_fgetl (std::FILE *); | |
2926 | 49 |
6108 | 50 extern OCTAVE_API std::string octave_fgets (std::FILE *, bool& eof); |
51 extern OCTAVE_API std::string octave_fgetl (std::FILE *, bool& eof); | |
3970 | 52 |
6108 | 53 extern "C" OCTAVE_API int octave_gethostname (char *, int); |
3803 | 54 |
10180 | 55 extern "C" OCTAVE_API void |
56 octave_qsort (void *base, size_t n, size_t size, | |
57 int (*cmp) (const void *, const void *)); | |
3613 | 58 |
10180 | 59 extern "C" OCTAVE_API int |
60 octave_strcasecmp (const char *s1, const char *s2); | |
3706 | 61 |
10180 | 62 extern "C" OCTAVE_API int |
63 octave_strncasecmp (const char *s1, const char *s2, size_t n); | |
6111 | 64 |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
65 template <typename T> |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
66 T |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
67 octave_read_value (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
68 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
69 T retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
70 is >> retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
71 return retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
72 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
73 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 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
|
78 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
79 // 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
|
80 inline double |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
81 octave_read_double (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
82 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
83 return octave_read_value<double> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
84 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
85 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
86 inline Complex |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
87 octave_read_complex (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
88 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
89 return octave_read_value<Complex> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
90 } |
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 inline float |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
93 octave_read_float (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
94 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
95 return octave_read_value<float> (is); |
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 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
98 inline FloatComplex |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
99 octave_read_float_complex (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
100 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
101 return octave_read_value<FloatComplex> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
102 } |
4130 | 103 |
10180 | 104 extern OCTAVE_API void |
105 octave_write_double (std::ostream& os, double dval); | |
106 | |
107 extern OCTAVE_API void | |
108 octave_write_complex (std::ostream& os, const Complex& cval); | |
4130 | 109 |
10180 | 110 extern OCTAVE_API void |
111 octave_write_float (std::ostream& os, float dval); | |
112 | |
113 extern OCTAVE_API void | |
114 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
|
115 |
5451 | 116 #ifdef HAVE_LOADLIBRARY_API |
10346
65d5776379c3
Reduce the amount of stuff included by windows.h and avoid min/max being #define-d
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10239
diff
changeset
|
117 #define WIN32_LEAN_AND_MEAN |
5451 | 118 #include <windows.h> |
10180 | 119 extern "C" OCTAVE_API void * |
120 octave_w32_library_search (HINSTANCE handle, const char *name); | |
1967 | 121 #endif |
122 | |
10180 | 123 extern "C" OCTAVE_API pid_t |
124 octave_waitpid (pid_t pid, int *status, int options); | |
10346
65d5776379c3
Reduce the amount of stuff included by windows.h and avoid min/max being #define-d
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10239
diff
changeset
|
125 |
65d5776379c3
Reduce the amount of stuff included by windows.h and avoid min/max being #define-d
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10239
diff
changeset
|
126 #endif |