Mercurial > hg > octave-nkf
annotate liboctave/array/MSparse.h @ 19887:3db04b75c7c0
do not set text encoding for strings to utf-8 on windows (bug #44103)
* octave-gui.cc (octave_start_gui): only use setCodecForCStrings when not
building for windows
author | Torsten <ttl@justmail.de> |
---|---|
date | Mon, 09 Feb 2015 22:09:36 +0100 |
parents | 49a5a4be04a1 |
children | 4197fc428c7d |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
3 Copyright (C) 2004-2013 David Bateman |
11523 | 4 Copyright (C) 1998-2004 Andy Adler |
7016 | 5 |
6 This file is part of Octave. | |
5164 | 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. | |
5164 | 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/>. | |
5164 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_MSparse_h) | |
25 #define octave_MSparse_h 1 | |
26 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
27 #include "MArray.h" |
5164 | 28 |
29 #include "Sparse.h" | |
30 | |
31 // Two dimensional sparse array with math ops. | |
32 | |
33 // But first, some preprocessor abuse... | |
34 | |
35 #include "MSparse-defs.h" | |
36 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
37 SPARSE_OPS_FORWARD_DECLS (MSparse, MArray, ) |
5164 | 38 |
39 template <class T> | |
40 class | |
41 MSparse : public Sparse<T> | |
42 { | |
43 public: | |
44 | |
45 MSparse (void) : Sparse<T> () { } | |
46 | |
5275 | 47 MSparse (octave_idx_type n, octave_idx_type m) : Sparse<T> (n, m) { } |
5164 | 48 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
49 MSparse (const dim_vector& dv, octave_idx_type nz = 0) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
50 : Sparse<T> (dv, nz) { } |
6823 | 51 |
5164 | 52 MSparse (const MSparse<T>& a) : Sparse<T> (a) { } |
53 | |
54 MSparse (const MSparse<T>& a, const dim_vector& dv) : Sparse<T> (a, dv) { } | |
55 | |
56 MSparse (const Sparse<T>& a) : Sparse<T> (a) { } | |
57 | |
10516
f0266ee4aabe
optimize some special indexing & assignment cases
Jaroslav Hajek <highegg@gmail.com>
parents:
10480
diff
changeset
|
58 template <class U> |
f0266ee4aabe
optimize some special indexing & assignment cases
Jaroslav Hajek <highegg@gmail.com>
parents:
10480
diff
changeset
|
59 MSparse (const Sparse<U>& a) : Sparse<T> (a) { } |
f0266ee4aabe
optimize some special indexing & assignment cases
Jaroslav Hajek <highegg@gmail.com>
parents:
10480
diff
changeset
|
60 |
10479
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
61 MSparse (const Array<T>& a, const idx_vector& r, const idx_vector& c, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
62 octave_idx_type nr = -1, octave_idx_type nc = -1, |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10516
diff
changeset
|
63 bool sum_terms = true, octave_idx_type nzm = -1) |
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10516
diff
changeset
|
64 : Sparse<T> (a, r, c, nr, nc, sum_terms, nzm) { } |
10479
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
65 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
66 explicit MSparse (octave_idx_type r, octave_idx_type c, T val) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
67 : Sparse<T> (r, c, val) { } |
5164 | 68 |
13030
b646413c3d0e
Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11586
diff
changeset
|
69 explicit MSparse (const PermMatrix& a) : Sparse<T>(a) { } |
b646413c3d0e
Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11586
diff
changeset
|
70 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
71 MSparse (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
72 : Sparse<T> (r, c, num_nz) { } |
5164 | 73 |
74 ~MSparse (void) { } | |
75 | |
76 MSparse<T>& operator = (const MSparse<T>& a) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
77 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
78 Sparse<T>::operator = (a); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
79 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
80 } |
5164 | 81 |
5275 | 82 MSparse<T>& insert (const Sparse<T>& a, octave_idx_type r, octave_idx_type c) |
5164 | 83 { |
84 Sparse<T>::insert (a, r, c); | |
85 return *this; | |
86 } | |
87 | |
6823 | 88 MSparse<T>& insert (const Sparse<T>& a, const Array<octave_idx_type>& indx) |
89 { | |
90 Sparse<T>::insert (a, indx); | |
91 return *this; | |
92 } | |
93 | |
5164 | 94 MSparse<T> transpose (void) const { return Sparse<T>::transpose (); } |
95 | |
96 MSparse<T> squeeze (void) const { return Sparse<T>::squeeze (); } | |
97 | |
98 MSparse<T> reshape (const dim_vector& new_dims) const | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 { return Sparse<T>::reshape (new_dims); } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
100 |
5275 | 101 MSparse<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
102 { return Sparse<T>::permute (vec, inv); } |
5164 | 103 |
5275 | 104 MSparse<T> ipermute (const Array<octave_idx_type>& vec) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
105 { return Sparse<T>::ipermute (vec); } |
5164 | 106 |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7602
diff
changeset
|
107 MSparse<T> diag (octave_idx_type k = 0) const |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7602
diff
changeset
|
108 { |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7602
diff
changeset
|
109 return Sparse<T>::diag (k); |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7602
diff
changeset
|
110 } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7602
diff
changeset
|
111 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
112 // FIXME: should go away. |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
113 template <class U> |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
114 MSparse<U> |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
115 map (U (&fcn) (T)) const |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
116 { return Sparse<T>::template map<U> (fcn); } |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
117 |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
118 template <class U> |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
119 MSparse<U> |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
120 map (U (&fcn) (const T&)) const |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
121 { return Sparse<T>::template map<U> (fcn); } |
7602
7bfaa9611558
Rewrite sparse mappers in terms of a functor template function
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
122 |
5164 | 123 // Currently, the OPS functions don't need to be friends, but that |
124 // may change. | |
125 | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
126 // SPARSE_OPS_FRIEND_DECLS (MSparse, MArray) |
5164 | 127 }; |
128 | |
129 #endif |