15#include "matpack_data.h"
34 if (needleind.
nelem() == 1 && needleind[0] == -1) {
39 for (Index i = 0; i < needleind.
nelem(); i++) {
40 if (haystack.
nelem() <= needleind[i]) {
42 os <<
"The input vector only has " << haystack.
nelem()
43 <<
" elements. But one of the needle indexes is " << needleind[i]
45 os <<
"The indexes must be between 0 and " << haystack.
nelem() - 1;
46 throw runtime_error(os.str());
47 }
else if (needleind[i] < 0) {
49 os <<
"One of the needle indexes is " << needleind[i] <<
"." << endl;
50 os <<
"The indexes must be between 0 and " << haystack.
nelem() - 1;
51 throw runtime_error(os.str());
53 dummy[i] = haystack[needleind[i]];
72 if (needleind.
nelem() == 1 && needleind[0] == -1) {
77 for (Index i = 0; i < needleind.
nelem(); i++) {
78 if (haystack.
nelem() <= needleind[i]) {
80 os <<
"The input vector only has " << haystack.
nelem()
81 <<
" elements. But one of the needle indexes is " << needleind[i]
83 os <<
"The indexes must be between 0 and " << haystack.
nelem() - 1;
84 throw runtime_error(os.str());
85 }
else if (needleind[i] < 0) {
87 os <<
"One of the needle indexes is " << needleind[i] <<
"." << endl;
88 os <<
"The indexes must be between 0 and " << haystack.
nelem() - 1;
89 throw runtime_error(os.str());
91 dummy[i] = haystack[needleind[i]];
105 Select(needles, haystack, needleind, verbosity);
112 const Vector& haystack,
118 Vector dummy(needleind.
nelem());
121 if (needleind.
nelem() == 1 && needleind[0] == -1) {
126 for (Index i = 0; i < needleind.
nelem(); i++) {
127 if (haystack.nelem() <= needleind[i]) {
129 os <<
"The input vector only has " << haystack.nelem()
130 <<
" elements. But one of the needle indexes is " << needleind[i]
132 os <<
"The indexes must be between 0 and " << haystack.
nelem() - 1;
133 throw runtime_error(os.str());
134 }
else if (needleind[i] < 0) {
136 os <<
"One of the needle indexes is " << needleind[i] <<
"." << endl;
137 os <<
"The indexes must be between 0 and " << haystack.
nelem() - 1;
138 throw runtime_error(os.str());
140 dummy[i] = haystack[needleind[i]];
150 const Matrix& haystack,
156 Matrix dummy(needleind.
nelem(), haystack.ncols());
159 if (needleind.
nelem() == 1 && needleind[0] == -1) {
164 for (Index i = 0; i < needleind.
nelem(); i++) {
165 if (haystack.nrows() <= needleind[i]) {
167 os <<
"The input matrix only has " << haystack.nrows()
168 <<
" rows. But one of the needle indexes is " << needleind[i] <<
"."
170 os <<
"The indexes must be between 0 and " << haystack.nrows() - 1;
171 throw runtime_error(os.str());
172 }
else if (needleind[i] < 0) {
174 os <<
"One of the needle indexes is " << needleind[i] <<
"." << endl;
175 os <<
"The indexes must be between 0 and " << haystack.nrows() - 1;
176 throw runtime_error(os.str());
178 dummy(i, joker) = haystack(needleind[i], joker);
188 const Sparse& haystack,
196 Sparse dummy(needleind.
nelem(), haystack.ncols());
199 if (needleind.
nelem() == 1 && needleind[0] == -1) {
204 for (Index i = 0; i < needleind.
nelem(); i++) {
205 if (haystack.nrows() <= needleind[i]) {
207 os <<
"The input matrix only has " << haystack.nrows()
208 <<
" rows. But one of the needle indexes is " << needleind[i] <<
"."
210 os <<
"The indexes must be between 0 and " << haystack.nrows() - 1;
211 throw runtime_error(os.str());
212 }
else if (needleind[i] < 0) {
214 os <<
"One of the needle indexes is " << needleind[i] <<
"." << endl;
215 os <<
"The indexes must be between 0 and " << haystack.nrows() - 1;
216 throw runtime_error(os.str());
222 for (Index j = 0; j < haystack.ncols(); ++j) {
223 Numeric value = haystack(needleind[i], j);
224 if (0 != value) dummy.rw(i, j) = value;
229 if (dummy.nnz() == haystack.nnz()) {
231 out3 <<
" Number of nonzero elements has stayed the same.\n";
233 out3 <<
" Number of nonzero elements reduced from " << haystack.nnz()
234 <<
" to " << dummy.nnz() <<
".\n";
Declarations for agendas.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
void Select(Array< T > &needles, const Array< T > &haystack, const ArrayOfIndex &needleind, const Verbosity &)
Declarations having to do with the four output streams.
This file contains the definition of String, the ARTS string class.
This file contains the Workspace class.