ARTS  2.2.66
m_basic_types.cc
Go to the documentation of this file.
1 /* Copyright (C) 2002-2012
2  Patrick Eriksson <Patrick.Eriksson@chalmers.se>
3  Stefan Buehler <sbuehler@ltu.se>
4 
5  This program is free software; you can redistribute it and/or modify it
6  under the terms of the GNU General Public License as published by the
7  Free Software Foundation; either version 2, or (at your option) any
8  later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18  USA. */
19 
20 
21 
22 /*===========================================================================
23  === File description
24  ===========================================================================*/
25 
45 /*===========================================================================
46  === External declarations
47  ===========================================================================*/
48 
49 #include <cmath>
50 #include "arts.h"
51 #include "array.h"
52 #include "matpackI.h"
53 #include "matpackII.h"
54 #include "matpackIII.h"
55 #include "matpackIV.h"
56 #include "matpackV.h"
57 #include "matpackVI.h"
58 #include "matpackVII.h"
59 #include "mystring.h"
60 #include "exceptions.h"
61 #include "make_array.h"
62 #include "math_funcs.h"
63 #include "messages.h"
64 #include "logic.h"
65 #include "sorting.h"
66 #include "gridded_fields.h"
67 
68 
69 /*===========================================================================
70  === The functions (in alphabetical order)
71  ===========================================================================*/
72 
73 
74 /* Workspace method: Doxygen documentation will be auto-generated */
76  const ArrayOfIndex& values,
77  const Verbosity&)
78 {
79  aoi = values;
80 }
81 
82 
83 /* Workspace method: Doxygen documentation will be auto-generated */
85  const Index& nelem,
86  const Index& value,
87  const Verbosity&)
88 {
89  aoi.resize(nelem);
90  for( Index i=0; i<nelem; i++ )
91  aoi[i] = value;
92 }
93 
94 
95 /* Workspace method: Doxygen documentation will be auto-generated */
97  const Index& start,
98  const Index& stop,
99  const Index& step,
100  const Verbosity& verbosity)
101 {
102  CREATE_OUT2;
103  CREATE_OUT3;
104 
105  Index n = (Index) floor( (stop-start)/step ) + 1;
106  if (n < 1) n = 1;
107 
108  x.resize(n);
109 
110  for ( Index i = 0; i < n; i++ )
111  x[i] = start + i*step;
112 
113  out2 << " Creating a linearly spaced ArrayOfIndex.\n";
114  out3 << " length : " << x.nelem() << "\n";
115  out3 << " first value : " << x[0] << "\n";
116 
117  if ( x.nelem() > 1 )
118  {
119  out3 << " step size : " << x[1]-x[0] << "\n";
120  out3 << " last value : " << x[x.nelem()-1] << "\n";
121  }
122 }
123 
124 
125 /* Workspace method: Doxygen documentation will be auto-generated */
127  const ArrayOfString& sa2,
128  const Verbosity&)
129 {
130  sa.resize(sa2.nelem());
131  sa = sa2;
132 }
133 
134 
135 /* Workspace method: Doxygen documentation will be auto-generated */
136 void FlagOff(Index& x, const Verbosity&)
137 {
138  x = 0;
139 }
140 
141 
142 /* Workspace method: Doxygen documentation will be auto-generated */
143 void FlagOn(Index& x, const Verbosity&)
144 {
145  x = 1;
146 }
147 
148 
149 /* Workspace method: Doxygen documentation will be auto-generated */
150 void IndexSet(Index& x,
151  const Index& value,
152  const Verbosity&)
153 {
154  x = value;
155 }
156 
157 
158 /* Workspace method: Doxygen documentation will be auto-generated */
159 void IndexStepDown(Index& xout,
160  const Index& xin,
161  const Verbosity&)
162 {
163  xout = xin - 1;
164 }
165 
166 
167 /* Workspace method: Doxygen documentation will be auto-generated */
168 void IndexStepUp(Index& xout,
169  const Index& xin,
170  const Verbosity&)
171 {
172  xout = xin + 1;
173 }
174 
175 
176 /* Workspace method: Doxygen documentation will be auto-generated */
178  const Matrix& in,
179  const Numeric& value,
180  const Verbosity&)
181 {
182  // Note that in and out can be the same vector
183  if (&out==&in)
184  {
185  // Out and in are the same. Just add the scalar value.
186  out += value;
187  }
188  else
189  {
190  // Out and in are different. We first have to copy in to out,
191  // then add the scalar value.
192  out.resize( in.nrows(), in.ncols() );
193  out = in;
194  out += value;
195  }
196 }
197 
198 
199 /* Workspace method: Doxygen documentation will be auto-generated */
200 void MatrixMatrixMultiply(// WS Generic Output:
201  Matrix& Y,
202  // WS Generic Input:
203  const Matrix& M,
204  const Matrix& X,
205  const Verbosity&)
206 {
207  // Check that dimensions are right, M.ncols() must match X.nrows():
208  if (M.ncols()!=X.nrows())
209  {
210  ostringstream os;
211  os << "Matrix dimensions must be consistent!\n"
212  << "Matrix1.ncols() = " << M.ncols() << "\n"
213  << "Matrix2.nrows() = " << X.nrows();
214  throw runtime_error( os.str() );
215  }
216 
217  // Temporary for the result:
218  Matrix dummy( M.nrows(), X.ncols() );
219 
220  mult( dummy, M, X );
221 
222  // Copy result to Y:
223 
224  Y.resize( dummy.nrows(), dummy.ncols() );
225 
226  Y = dummy;
227 }
228 
229 /* Workspace method: Doxygen documentation will be auto-generated */
230 void Matrix1ColFromVector(// WS Generic Output:
231  Matrix& m,
232  // WS Generic Input:
233  const Vector& v,
234  const Verbosity&)
235 {
236  const Index nv = v.nelem();
237 
238  m.resize( nv, 1 );
239  m( joker,0 ) = v;
240 }
241 
242 
243 /* Workspace method: Doxygen documentation will be auto-generated */
244 void Matrix2ColFromVectors(// WS Generic Output:
245  Matrix& m,
246  // WS Generic Input:
247  const Vector& v1,
248  const Vector& v2,
249  const Verbosity&)
250 {
251  const Index nv = v1.nelem();
252 
253  if( v2.nelem() != nv )
254  throw runtime_error("Vectors must be of the same size.");
255 
256  m.resize( nv, 2 );
257  m( joker,0 ) = v1;
258  m( joker,1 ) = v2;
259 
260 }
261 
262 
263 /* Workspace method: Doxygen documentation will be auto-generated */
264 void Matrix3ColFromVectors(// WS Generic Output:
265  Matrix& m,
266  // WS Generic Input:
267  const Vector& v1,
268  const Vector& v2,
269  const Vector& v3,
270  const Verbosity&)
271 {
272  const Index nv = v1.nelem();
273 
274  if( v3.nelem() != nv || v2.nelem() != nv )
275  throw runtime_error("Vectors must be of the same size.");
276 
277  m.resize( nv, 3 );
278  m( joker,0 ) = v1;
279  m( joker,1 ) = v2;
280  m( joker,2 ) = v3;
281 }
282 
283 
284 /* Workspace method: Doxygen documentation will be auto-generated */
285 void Matrix1RowFromVector(// WS Generic Output:
286  Matrix& m,
287  // WS Generic Input:
288  const Vector& v,
289  const Verbosity&)
290 {
291  const Index nv = v.nelem();
292 
293  m.resize( 1, nv );
294  m( 0, joker ) = v;
295 }
296 
297 
298 /* Workspace method: Doxygen documentation will be auto-generated */
299 void Matrix2RowFromVectors(// WS Generic Output:
300  Matrix& m,
301  // WS Generic Input:
302  const Vector& v1,
303  const Vector& v2,
304  const Verbosity&)
305 {
306  const Index nv = v1.nelem();
307 
308  if( v2.nelem() != nv )
309  throw runtime_error("Vectors must be of the same size.");
310 
311  m.resize( 2, nv );
312  m( 0, joker ) = v1;
313  m( 1, joker ) = v2;
314 
315 }
316 
317 
318 /* Workspace method: Doxygen documentation will be auto-generated */
319 void Matrix3RowFromVectors(// WS Generic Output:
320  Matrix& m,
321  // WS Generic Input:
322  const Vector& v1,
323  const Vector& v2,
324  const Vector& v3,
325  const Verbosity&)
326 {
327  const Index nv = v1.nelem();
328 
329  if( v3.nelem() != nv || v2.nelem() != nv )
330  throw runtime_error("Vectors must be of the same size.");
331 
332  m.resize( 3, nv );
333  m( 0, joker ) = v1;
334  m( 1, joker ) = v2;
335  m( 2, joker ) = v3;
336 
337 }
338 
339 
340 /* Workspace method: Doxygen documentation will be auto-generated */
341 void MatrixScale(Matrix& out,
342  const Matrix& in,
343  const Numeric& value,
344  const Verbosity&)
345 {
346  // Note that in and out can be the same matrix
347  if (&out==&in)
348  {
349  // Out and in are the same. Just multiply by the scalar value.
350  out *= value;
351  }
352  else
353  {
354  // Out and in are different. We first have to copy in to out,
355  // then multiply by the scalar value.
356  out.resize( in.nrows(), in.ncols() );
357  out = in;
358  out *= value;
359  }
360 }
361 
362 
363 /* Workspace method: Doxygen documentation will be auto-generated */
364 void MatrixSet(Matrix& x,
365  const Matrix& values,
366  const Verbosity&)
367 {
368  x = values;
369 }
370 
371 
372 /* Workspace method: Doxygen documentation will be auto-generated */
374  const Index& nrows,
375  const Index& ncols,
376  const Numeric& value,
377  const Verbosity&)
378 {
379  x.resize( nrows, ncols );
380  x = value;
381 }
382 
383 
384 /* Workspace method: Doxygen documentation will be auto-generated */
385 void NumericAdd(Numeric& out,
386  const Numeric& in,
387  const Numeric& value,
388  const Verbosity&)
389 {
390  out = value + in;
391 }
392 
393 
394 /* Workspace method: Doxygen documentation will be auto-generated */
396  const Numeric& in,
397  const Numeric& value,
398  const Verbosity&)
399 {
400  out = in / value;
401 }
402 
403 
404 /* Workspace method: Doxygen documentation will be auto-generated */
406  const Numeric& in,
407  const Numeric& value,
408  const Verbosity&)
409 {
410  out = value * in;
411 }
412 
413 
414 /* Workspace method: Doxygen documentation will be auto-generated */
416  const Numeric& value,
417  const Verbosity&)
418 {
419  x = value;
420 }
421 
422 
423 /* Workspace method: Doxygen documentation will be auto-generated */
424 void SparseSparseMultiply(// WS Generic Output:
425  Sparse& Y,
426  // WS Generic Input:
427  const Sparse& M,
428  const Sparse& X,
429  const Verbosity&)
430 {
431  // Check that dimensions are right, M.ncols() must match X.nrows():
432  if (M.ncols()!=X.nrows())
433  {
434  ostringstream os;
435  os << "Matrix dimensions must be consistent!\n"
436  << "Matrix1.ncols() = " << M.ncols() << "\n"
437  << "Matrix2.nrows() = " << X.nrows();
438  throw runtime_error( os.str() );
439  }
440 
441  // Temporary for the result:
442  Sparse dummy( M.nrows(), X.ncols() );
443 
444  mult( dummy, M, X );
445 
446  // Copy result to Y:
447  Y = dummy;
448 }
449 
450 
451 /* Workspace method: Doxygen documentation will be auto-generated */
452 void StringSet(String& s,
453  const String& s2,
454  const Verbosity&)
455 {
456  s = s2;
457 }
458 
459 
460 /* Workspace method: Doxygen documentation will be auto-generated */
462  const Tensor3& in,
463  const Numeric& value,
464  const Verbosity&)
465 {
466  // Note that in and out can be the same vector
467  if (&out==&in) {
468  // Out and in are the same. Just multiply by the scalar value.
469  out += value;
470  } else {
471  // Out and in are different. We first have to copy in to out,
472  // then multiply by the scalar value.
473  out.resize( in.npages(), in.nrows(), in.ncols() );
474  out = in;
475  out += value;
476  }
477 }
478 
479 
480 /* Workspace method: Doxygen documentation will be auto-generated */
482  const Tensor3& in,
483  const Numeric& value,
484  const Verbosity&)
485 {
486  // Note that in and out can be the same vector
487  if (&out==&in) {
488  // Out and in are the same. Just multiply by the scalar value.
489  out *= value;
490  } else {
491  // Out and in are different. We first have to copy in to out,
492  // then multiply by the scalar value.
493  out.resize( in.npages(), in.nrows(), in.ncols() );
494  out = in;
495  out *= value;
496  }
497 }
498 
499 
500 /* Workspace method: Doxygen documentation will be auto-generated */
502  const Index& npages,
503  const Index& nrows,
504  const Index& ncols,
505  const Numeric& value,
506  const Verbosity& verbosity)
507 {
508  CREATE_OUT2;
509  CREATE_OUT3;
510 
511  x.resize( npages, nrows, ncols );
512  x = value;
513 
514  out2 << " Tensor3 = " << value << "\n";
515  out3 << " npages : " << npages << "\n";
516  out3 << " nrows : " << nrows << "\n";
517  out3 << " ncols : " << ncols << "\n";
518 }
519 
520 
521 /* Workspace method: Doxygen documentation will be auto-generated */
523  const Tensor4& in,
524  const Numeric& value,
525  const Verbosity&)
526 {
527  // Note that in and out can be the same vector
528  if (&out==&in) {
529  // Out and in are the same. Just multiply by the scalar value.
530  out += value;
531  } else {
532  // Out and in are different. We first have to copy in to out,
533  // then multiply by the scalar value.
534  out.resize( in.nbooks(), in.npages(), in.nrows(), in.ncols() );
535  out = in;
536  out += value;
537  }
538 }
539 
540 
541 /* Workspace method: Doxygen documentation will be auto-generated */
543  const Tensor4& in,
544  const Numeric& value,
545  const Verbosity&)
546 {
547  // Note that in and out can be the same vector
548  if (&out==&in) {
549  // Out and in are the same. Just multiply by the scalar value.
550  out *= value;
551  } else {
552  // Out and in are different. We first have to copy in to out,
553  // then multiply by the scalar value.
554  out.resize( in.nbooks(), in.npages(), in.nrows(), in.ncols() );
555  out = in;
556  out *= value;
557  }
558 }
559 
560 
561 /* Workspace method: Doxygen documentation will be auto-generated */
563  const Index& nbooks,
564  const Index& npages,
565  const Index& nrows,
566  const Index& ncols,
567  const Numeric& value,
568  const Verbosity& verbosity)
569 {
570  CREATE_OUT2;
571  CREATE_OUT3;
572 
573  x.resize( nbooks, npages, nrows, ncols );
574  x = value;
575 
576  out2 << " Tensor4 = " << value << "\n";
577  out3 << " nbooks : " << nbooks << "\n";
578  out3 << " npages : " << npages << "\n";
579  out3 << " nrows : " << nrows << "\n";
580  out3 << " ncols : " << ncols << "\n";
581 }
582 
583 
584 /* Workspace method: Doxygen documentation will be auto-generated */
586  const Tensor5& in,
587  const Numeric& value,
588  const Verbosity&)
589 {
590  // Note that in and out can be the same vector
591  if (&out==&in) {
592  // Out and in are the same. Just multiply by the scalar value.
593  out *= value;
594  } else {
595  // Out and in are different. We first have to copy in to out,
596  // then multiply by the scalar value.
597  out.resize( in.nshelves(), in.nbooks(), in.npages(),
598  in.nrows(), in.ncols() );
599  out = in;
600  out *= value;
601  }
602 }
603 
604 
605 /* Workspace method: Doxygen documentation will be auto-generated */
607  const Index& nshelves,
608  const Index& nbooks,
609  const Index& npages,
610  const Index& nrows,
611  const Index& ncols,
612  const Numeric& value,
613  const Verbosity& verbosity)
614 {
615  CREATE_OUT2;
616  CREATE_OUT3;
617 
618  x.resize( nshelves, nbooks, npages, nrows, ncols );
619  x = value;
620 
621  out2 << " Tensor5 = " << value << "\n";
622  out3 << " nshelves : " << nshelves << "\n";
623  out3 << " nbooks : " << nbooks << "\n";
624  out3 << " npages : " << npages << "\n";
625  out3 << " nrows : " << nrows << "\n";
626  out3 << " ncols : " << ncols << "\n";
627 }
628 
629 
630 /* Workspace method: Doxygen documentation will be auto-generated */
632  const Tensor6& in,
633  const Numeric& value,
634  const Verbosity&)
635 {
636  // Note that in and out can be the same vector
637  if (&out==&in) {
638  // Out and in are the same. Just multiply by the scalar value.
639  out *= value;
640  } else {
641  // Out and in are different. We first have to copy in to out,
642  // then multiply by the scalar value.
643  out.resize( in.nvitrines(), in.nshelves(), in.nbooks(),
644  in.npages(), in.nrows(), in.ncols() );
645  out = in;
646  out *= value;
647  }
648 }
649 
650 
651 /* Workspace method: Doxygen documentation will be auto-generated */
653  const Index& nvitrines,
654  const Index& nshelves,
655  const Index& nbooks,
656  const Index& npages,
657  const Index& nrows,
658  const Index& ncols,
659  const Numeric& value,
660  const Verbosity& verbosity)
661 {
662  CREATE_OUT2;
663  CREATE_OUT3;
664 
665  x.resize( nvitrines, nshelves, nbooks, npages, nrows, ncols );
666  x = value;
667 
668  out2 << " Tensor6 = " << value << "\n";
669  out3 << " nvitrines : " << nvitrines << "\n";
670  out3 << " nshelves : " << nshelves << "\n";
671  out3 << " nbooks : " << nbooks << "\n";
672  out3 << " npages : " << npages << "\n";
673  out3 << " nrows : " << nrows << "\n";
674  out3 << " ncols : " << ncols << "\n";
675 }
676 
677 
678 /* Workspace method: Doxygen documentation will be auto-generated */
680  const Tensor7& in,
681  const Numeric& value,
682  const Verbosity&)
683 {
684  // Note that in and out can be the same vector
685  if (&out==&in) {
686  // Out and in are the same. Just multiply by the scalar value.
687  out *= value;
688  } else {
689  // Out and in are different. We first have to copy in to out,
690  // then multiply by the scalar value.
691  out.resize( in.nlibraries(), in.nvitrines(), in.nshelves(),
692  in.nbooks(), in.npages(), in.nrows(), in.ncols() );
693  out = in;
694  out *= value;
695  }
696 }
697 
698 
699 /* Workspace method: Doxygen documentation will be auto-generated */
701  const Index& nlibraries,
702  const Index& nvitrines,
703  const Index& nshelves,
704  const Index& nbooks,
705  const Index& npages,
706  const Index& nrows,
707  const Index& ncols,
708  const Numeric& value,
709  const Verbosity& verbosity)
710 {
711  CREATE_OUT2;
712  CREATE_OUT3;
713 
714  x.resize( nlibraries, nvitrines, nshelves, nbooks, npages, nrows, ncols );
715  x = value;
716 
717  out2 << " Tensor7 = " << value << "\n";
718  out3 << " nlibraries : " << nlibraries << "\n";
719  out3 << " nvitrines : " << nvitrines << "\n";
720  out3 << " nshelves : " << nshelves << "\n";
721  out3 << " nbooks : " << nbooks << "\n";
722  out3 << " npages : " << npages << "\n";
723  out3 << " nrows : " << nrows << "\n";
724  out3 << " ncols : " << ncols << "\n";
725 }
726 
727 
728 /* Workspace method: Doxygen documentation will be auto-generated */
730  const Vector& in,
731  const Numeric& value,
732  const Verbosity&)
733 {
734  // Note that in and out can be the same vector
735  if (&out==&in)
736  {
737  // Out and in are the same. Just add the scalar value.
738  out += value;
739  }
740  else
741  {
742  // Out and in are different. We first have to copy in to out,
743  // then add the scalar value.
744  out.resize( in.nelem() );
745  out = in;
746  out += value;
747  }
748 }
749 
750 
751 /* Workspace method: Doxygen documentation will be auto-generated */
752 void VectorCrop( Vector& out,
753  const Vector& in,
754  const Numeric& min_value,
755  const Numeric& max_value,
756  const Verbosity&)
757 {
758  const Index nin = in.nelem();
759 
760  Index nout = 0;
761  //
762  for( Index i=0; i<nin; i++ )
763  {
764  if( in[i] >= min_value && in[i] <= max_value )
765  { nout += 1; }
766  }
767 
768  // Make copy if in-vector, as it also can be the out one
769  Vector c(in);
770 
771  out.resize( nout );
772 
773  nout = 0;
774  //
775  for( Index i=0; i<nin; i++ )
776  {
777  if( c[i] >= min_value && c[i] <= max_value )
778  {
779  out[nout] = c[i];
780  nout += 1;
781  }
782  }
783 }
784 
785 
786 /* Workspace method: Doxygen documentation will be auto-generated */
787 void VectorFlip(Vector& out,
788  const Vector& in,
789  const Verbosity&)
790 {
791  const Index n = in.nelem();
792 
793  // Note that in and out can be the same vector
794  if (&out==&in)
795  {
796  // Out and in are the same. A copy is needed
797  const Vector v = in;
798  for( Index i=0; i<n; i++ )
799  out[i] = v[n-1-i];
800  }
801  else
802  {
803  // Out and in are different.
804  out.resize( n );
805  for( Index i=0; i<n; i++ )
806  out[i] = in[n-1-i];
807  }
808 }
809 
810 /* Workspace method: Doxygen documentation will be auto-generated */
811 void VectorInsertGridPoints(// WS Generic Output:
812  Vector& og, // Output grid
813  // WS Generic Input:
814  const Vector& ingrid, // Input grid
815  const Vector& points, // Points to insert
816  const Verbosity& verbosity)
817 {
818  CREATE_OUT2;
819  CREATE_OUT3;
820 
821  // First make duplikates of the input vectors, in case one of them
822  // happens to be identical to the output vector. Also, we can fool
823  // around with these, if we want.
824  Vector ig(ingrid);
825  Vector p(points);
826 
827  // Check how the input grid is sorted. If the grid is sorted in
828  // descending order, we simply turn it around. (But don't
829  // forget to turn it back at the end!)
830  Index ascending; // 1=ascending, 0=descending
831  if (is_increasing(ig))
832  {
833  ascending = 1;
834  }
835  else if (is_decreasing(ig))
836  {
837  ascending = 0;
838 
839  // Turn grid round.
840 
841  // Copy ig to dummy vector in reverse order:
842  const Vector dummy = ig[Range(ig.nelem()-1,ig.nelem(),-1)];
843 
844  // Copy dummy back to ig vector:
845  ig = dummy;
846  }
847  else
848  {
849  ostringstream os;
850  os << "The input Vector must be either\n"
851  << "strictly increasing or strictly decreasing,\n"
852  << "but this is not the case.\n";
853  os << "The vector contains:\n"
854  << ig;
855  throw runtime_error( os.str() );
856  }
857 
858  // Sort also the vector of points to insert in increasing order:
859  {
860  ArrayOfIndex si; // Sorted indices
861  get_sorted_indexes (si, p); // Get sorted p indices
862  const Vector dummy = p; // Copy p to dummy
863  // Copy back dummy to p in right order:
864  for (Index j = 0; j < p.nelem(); j++)
865  p[j] = dummy[si[j]];
866  }
867 
868  // The idea is to step through both ig and p, and build up the
869  // output in a temporary array.
870  Array<Numeric> x;
871  Index iig=0, ip=0; // indices to ig and p
872  Index sk=0; // skip count
873  while ( iig<ig.nelem() && ip<p.nelem() )
874  {
875  if ( p[ip]<ig[iig] )
876  {
877  x.push_back(p[ip]);
878  ++ip;
879  }
880  else if ( p[ip]>ig[iig] )
881  {
882  x.push_back(ig[iig]);
883  ++iig;
884  }
885  else
886  {
887  out3 << " Skipping point " << p[ip] << ", which is already "
888  << "in the original grid.\n";
889  ++ip;
890  ++sk;
891  }
892  }
893 
894  out2 << " " << sk << " points skipped.\n";
895 
896  // Add remaining points of either p or ig, depending on which is
897  // longer:
898  if ( ip==p.nelem() )
899  {
900  // p has reached its end.
901  while ( iig<ig.nelem() )
902  {
903  x.push_back(ig[iig]);
904  ++iig;
905  }
906  }
907  else if ( iig==ig.nelem() )
908  {
909  // ig has reached its end
910  while ( ip<p.nelem() )
911  {
912  x.push_back(p[ip]);
913  ++ip;
914  }
915  }
916  else
917  {
918  // We should never be here.
919  assert(false);
920  arts_exit();
921  }
922 
923  // Ok, x should now contain the new grid.
924 
925  og.resize(x.nelem());
926 
927  // Copy to result vector, turn around if necessary.
928  if (ascending)
929  for ( Index i=0; i<x.nelem(); ++i )
930  og[i] = x[i]; // Just copy.
931  else
932  for ( Index i=0; i<x.nelem(); ++i )
933  og[i] = x[x.nelem()-1-i]; // Copy in reverse order.
934 
935 }
936 
937 
938 /* Workspace method: Doxygen documentation will be auto-generated */
940  const Numeric& start,
941  const Numeric& stop,
942  const Numeric& step,
943  const Verbosity& verbosity)
944 {
945  CREATE_OUT2;
946  CREATE_OUT3;
947 
948  linspace(x,start,stop,step);
949 
950  out2 << " Creating a linearly spaced vector.\n";
951  out3 << " length : " << x.nelem() << "\n";
952  out3 << " first value : " << x[0] << "\n";
953 
954  if ( x.nelem() > 1 )
955  {
956  out3 << " step size : " << x[1]-x[0] << "\n";
957  out3 << " last value : " << x[x.nelem()-1] << "\n";
958  }
959 }
960 
961 /* Workspace method: Doxygen documentation will be auto-generated */
963  const Numeric& start,
964  const Numeric& stop,
965  const Numeric& step,
966  const Verbosity& verbosity)
967 {
968  CREATE_OUT2;
969  CREATE_OUT3;
970 
971  linspace(x,log(start),log(stop),step);
972  transform(x,exp,x);
973 
974  out2 << " Creating a logarithmically spaced vector.\n";
975  out3 << " length : " << x.nelem() << "\n";
976  out3 << " first value : " << x[0] << "\n";
977 
978  if ( x.nelem() > 1 )
979  {
980  out3 << " step size : " << x[1]-x[0] << "\n";
981  out3 << " last value : " << x[x.nelem()-1] << "\n";
982  }
983 }
984 
985 /* Workspace method: Doxygen documentation will be auto-generated */
986 void VectorMatrixMultiply(// WS Generic Output:
987  Vector& y,
988  // WS Generic Input:
989  const Matrix& M,
990  const Vector& x,
991  const Verbosity&)
992 {
993  // Check that dimensions are right, x must match columns of M:
994  if (M.ncols()!=x.nelem())
995  {
996  ostringstream os;
997  os << "Matrix and vector dimensions must be consistent!\n"
998  << "Matrix.ncols() = " << M.ncols() << "\n"
999  << "Vector.nelem() = " << x.nelem();
1000  throw runtime_error( os.str() );
1001  }
1002 
1003  // Temporary for the result:
1004  Vector dummy( M.nrows() );
1005 
1006  mult(dummy,M,x);
1007 
1008  y.resize(dummy.nelem());
1009 
1010  y = dummy;
1011 }
1012 
1013 /* Workspace method: Doxygen documentation will be auto-generated */
1015  const Index& n,
1016  const Numeric& start,
1017  const Numeric& stop,
1018  const Verbosity& verbosity)
1019 {
1020  CREATE_OUT2;
1021  CREATE_OUT3;
1022 
1023  if ( n<2 )
1024  throw runtime_error("The number of points must be > 1.");
1025  nlinspace(x,start,stop,n);
1026 
1027  out2 << " Creating a linearly spaced vector.\n";
1028  out3 << " length : " << n << "\n";
1029  out3 << " first value : " << x[0] << "\n";
1030 
1031  if ( x.nelem() > 1 )
1032  {
1033  out3 << " step size : " << x[1]-x[0] << "\n";
1034  out3 << " last value : " << x[x.nelem()-1] << "\n";
1035  }
1036 }
1037 
1038 
1039 /* Workspace method: Doxygen documentation will be auto-generated */
1041  const Index& n,
1042  const Numeric& start,
1043  const Numeric& stop,
1044  const Verbosity& verbosity)
1045 {
1046  CREATE_OUT2;
1047  CREATE_OUT3;
1048 
1049  if ( n<2 )
1050  throw runtime_error("The number of points must be > 1.");
1051  if ( (start<=0) || (stop<=0) )
1052  throw runtime_error("Only positive numbers are allowed.");
1053 
1054  nlogspace(x,start,stop,n);
1055 
1056  out2 << " Creating a logarithmically spaced vector.\n";
1057  out3 << " length : " << n << "\n";
1058  out3 << " first value : " << x[0] << "\n";
1059 
1060  if ( x.nelem() > 1 )
1061  out3 << " last value : " << x[x.nelem()-1] << "\n";
1062 }
1063 
1064 
1065 /* Workspace method: Doxygen documentation will be auto-generated */
1067  const Vector& in,
1068  const Numeric& value,
1069  const Verbosity&)
1070 {
1071  // Note that in and out can be the same vector
1072  if (&out==&in)
1073  {
1074  // Out and in are the same. Just multiply by the scalar value.
1075  out *= value;
1076  }
1077  else
1078  {
1079  // Out and in are different. We first have to copy in to out,
1080  // then multiply by the scalar value.
1081  out.resize( in.nelem() );
1082  out = in;
1083  out *= value;
1084  }
1085 }
1086 
1087 
1088 /* Workspace method: Doxygen documentation will be auto-generated */
1090  const Index& n,
1091  const Numeric& value,
1092  const Verbosity& verbosity)
1093 {
1094  CREATE_OUT2;
1095  CREATE_OUT3;
1096 
1097  x.resize(n);
1098  x = value;
1099 
1100  out2 << " Creating a constant vector.\n";
1101  out3 << " length : " << n << "\n";
1102  out3 << " value : " << value << "\n";
1103 }
1104 
1105 
1106 /* Workspace method: Doxygen documentation will be auto-generated */
1108  const Vector& values,
1109  const Verbosity&)
1110 {
1111  x = values;
1112 }
1113 
1114 
1115 /* Workspace method: Doxygen documentation will be auto-generated */
1116 void Compare(const Numeric& var1,
1117  const Numeric& var2,
1118  const Numeric& maxabsdiff,
1119  const String& error_message,
1120  const String& var1name,
1121  const String& var2name,
1122  const String&,
1123  const String&,
1124  const Verbosity& verbosity)
1125 {
1126  const Numeric maxdiff = var1-var2;
1127  if( abs(maxdiff) > maxabsdiff )
1128  {
1129  ostringstream os;
1130  os << var1name << "-" << var2name << " FAILED!\n";
1131  if (error_message.length()) os << error_message << "\n";
1132  os << "Max allowed deviation set to: " << maxabsdiff << endl
1133  << "but the value deviates with: " << maxdiff << endl;
1134  throw runtime_error(os.str());
1135  }
1136 
1137  CREATE_OUT2;
1138  out2 << " " << var1name << "-" << var2name
1139  << " OK (maximum difference = " << maxdiff << ").\n";
1140 }
1141 
1142 
1143 /* Workspace method: Doxygen documentation will be auto-generated */
1144 void Compare(const Vector& var1,
1145  const Vector& var2,
1146  const Numeric& maxabsdiff,
1147  const String& error_message,
1148  const String& var1name,
1149  const String& var2name,
1150  const String&,
1151  const String&,
1152  const Verbosity& verbosity)
1153 {
1154  const Index n = var1.nelem();
1155 
1156  if( var2.nelem() != n )
1157  {
1158  ostringstream os;
1159  os << var1name << " (" << n << ") and "
1160  << var2name << " (" << var2.nelem() << ") do not have the same size.";
1161  throw runtime_error(os.str());
1162  }
1163 
1164  Numeric maxdiff = 0.0;
1165  for( Index i=0; i <n; i++ )
1166  {
1167  const Numeric diff = var1[i] - var2[i];
1168  if( abs(diff) > abs(maxdiff) )
1169  { maxdiff = diff; }
1170  }
1171 
1172  if( abs(maxdiff) > maxabsdiff )
1173  {
1174  ostringstream os;
1175  os << var1name << "-" << var2name << " FAILED!\n";
1176  if (error_message.length()) os << error_message << "\n";
1177  os << "Max allowed deviation set to: " << maxabsdiff << endl
1178  << "but the vectors deviate with: " << maxdiff << endl;
1179  throw runtime_error(os.str());
1180  }
1181 
1182  CREATE_OUT2;
1183  out2 << " " << var1name << "-" << var2name
1184  << " OK (maximum difference = " << maxdiff << ").\n";
1185 }
1186 
1187 
1188 /* Workspace method: Doxygen documentation will be auto-generated */
1189 void Compare(const Matrix& var1,
1190  const Matrix& var2,
1191  const Numeric& maxabsdiff,
1192  const String& error_message,
1193  const String& var1name,
1194  const String& var2name,
1195  const String&,
1196  const String&,
1197  const Verbosity& verbosity)
1198 {
1199  const Index nrows = var1.nrows();
1200  const Index ncols = var1.ncols();
1201 
1202  if( var2.nrows() != nrows || var2.ncols() != ncols )
1203  {
1204  ostringstream os;
1205  os << var1name << " (" << nrows << "," << ncols << ") and "
1206  << var2name << " (" << var2.nrows() << "," << var2.ncols()
1207  << ") do not have the same size.";
1208  throw runtime_error(os.str());
1209  }
1210 
1211  Numeric maxdiff = 0.0;
1212 
1213  for( Index r=0; r<nrows; r++ )
1214  {
1215  for( Index c=0; c<ncols; c++ )
1216  {
1217  const Numeric diff = var1(r,c) - var2(r,c);
1218  if( abs(diff) > abs(maxdiff) )
1219  { maxdiff = diff; }
1220  }
1221  }
1222 
1223  if( abs(maxdiff) > maxabsdiff )
1224  {
1225  ostringstream os;
1226  os << var1name << "-" << var2name << " FAILED!\n";
1227  if (error_message.length()) os << error_message << "\n";
1228  os << "Max allowed deviation set to : " << maxabsdiff << endl
1229  << "but the matrices deviate with: " << maxdiff << endl;
1230  throw runtime_error(os.str());
1231  }
1232 
1233  CREATE_OUT2;
1234  out2 << " " << var1name << "-" << var2name
1235  << " OK (maximum difference = " << maxdiff << ").\n";
1236 }
1237 
1238 
1239 /* Workspace method: Doxygen documentation will be auto-generated */
1240 void Compare(const Tensor3& var1,
1241  const Tensor3& var2,
1242  const Numeric& maxabsdiff,
1243  const String& error_message,
1244  const String& var1name,
1245  const String& var2name,
1246  const String&,
1247  const String&,
1248  const Verbosity& verbosity)
1249 {
1250  const Index ncols = var1.ncols();
1251  const Index nrows = var1.nrows();
1252  const Index npages = var1.npages();
1253 
1254  if(var2.ncols() != ncols ||
1255  var2.nrows() != nrows ||
1256  var2.npages() != npages )
1257  {
1258  ostringstream os;
1259  os << var1name << " and " << var2name << " do not have the same size.";
1260  throw runtime_error(os.str());
1261  }
1262 
1263  Numeric maxdiff = 0.0;
1264 
1265  for( Index c=0; c<ncols; c++ )
1266  for( Index r=0; r<nrows; r++ )
1267  for( Index p=0; p<npages; p++ )
1268  {
1269  const Numeric diff = var1(p,r,c) - var2(p,r,c);
1270  if( abs(diff) > abs(maxdiff) )
1271  { maxdiff = diff; }
1272  }
1273 
1274  if( abs(maxdiff) > maxabsdiff )
1275  {
1276  ostringstream os;
1277  os << var1name << "-" << var2name << " FAILED!\n";
1278  if (error_message.length()) os << error_message << "\n";
1279  os << "Max allowed deviation set to : " << maxabsdiff << endl
1280  << "but the tensors deviate with: " << maxdiff << endl;
1281  throw runtime_error(os.str());
1282  }
1283 
1284  CREATE_OUT2;
1285  out2 << " " << var1name << "-" << var2name
1286  << " OK (maximum difference = " << maxdiff << ").\n";
1287 }
1288 
1289 
1290 /* Workspace method: Doxygen documentation will be auto-generated */
1291 void Compare(const Tensor7& var1,
1292  const Tensor7& var2,
1293  const Numeric& maxabsdiff,
1294  const String& error_message,
1295  const String& var1name,
1296  const String& var2name,
1297  const String&,
1298  const String&,
1299  const Verbosity& verbosity)
1300 {
1301  const Index ncols = var1.ncols();
1302  const Index nrows = var1.nrows();
1303  const Index npages = var1.npages();
1304  const Index nbooks = var1.nbooks();
1305  const Index nshelves = var1.nshelves();
1306  const Index nvitrines = var1.nvitrines();
1307  const Index nlibraries = var1.nlibraries();
1308 
1309  if(var2.ncols() != ncols ||
1310  var2.nrows() != nrows ||
1311  var2.npages() != npages ||
1312  var2.nbooks() != nbooks ||
1313  var2.nshelves() != nshelves ||
1314  var2.nvitrines() != nvitrines ||
1315  var2.nlibraries() != nlibraries )
1316  {
1317  ostringstream os;
1318  os << var1name << " and " << var2name << " do not have the same size.";
1319  throw runtime_error(os.str());
1320  }
1321 
1322  Numeric maxdiff = 0.0;
1323 
1324  for( Index c=0; c<ncols; c++ )
1325  for( Index r=0; r<nrows; r++ )
1326  for( Index p=0; p<npages; p++ )
1327  for( Index b=0; b<nbooks; b++ )
1328  for( Index s=0; s<nshelves; s++ )
1329  for( Index v=0; v<nvitrines; v++ )
1330  for( Index l=0; l<nlibraries; l++ )
1331  {
1332  const Numeric diff = var1(l,v,s,b,p,r,c) - var2(l,v,s,b,p,r,c);
1333  if( abs(diff) > abs(maxdiff) )
1334  { maxdiff = diff; }
1335  }
1336 
1337 
1338  if( abs(maxdiff) > maxabsdiff )
1339  {
1340  ostringstream os;
1341  os << var1name << "-" << var2name << " FAILED!\n";
1342  if (error_message.length()) os << error_message << "\n";
1343  os << "Max allowed deviation set to : " << maxabsdiff << endl
1344  << "but the tensors deviate with: " << maxdiff << endl;
1345  throw runtime_error(os.str());
1346  }
1347 
1348  CREATE_OUT2;
1349  out2 << " " << var1name << "-" << var2name
1350  << " OK (maximum difference = " << maxdiff << ").\n";
1351 }
1352 
1353 
1354 /* Workspace method: Doxygen documentation will be auto-generated */
1355 void Compare(const ArrayOfVector& var1,
1356  const ArrayOfVector& var2,
1357  const Numeric& maxabsdiff,
1358  const String& error_message,
1359  const String& var1name,
1360  const String& var2name,
1361  const String&,
1362  const String&,
1363  const Verbosity& verbosity)
1364 {
1365  if( var1.nelem() != var2.nelem() )
1366  {
1367  ostringstream os;
1368  os << "The two arrays do not have the same size." << endl
1369  << var1name << " nelem: " << var1.nelem() << endl
1370  << var2name << " nelem: " << var2.nelem() << endl;
1371  throw runtime_error(os.str());
1372  }
1373 
1374  bool failed = false;
1375  ostringstream fail_msg;
1376  for (Index i = 0; i < var1.nelem(); i++)
1377  {
1378  try
1379  {
1380  ostringstream vn1, vn2;
1381  vn1 << var1name << "[" << i << "]";
1382  vn2 << var2name << "[" << i << "]";
1383  Compare(var1[i], var2[i], maxabsdiff, error_message,
1384  vn1.str(), vn2.str(), "", "", verbosity);
1385  }
1386  catch (runtime_error e)
1387  {
1388  failed = true;
1389  fail_msg << endl << e.what() << endl
1390  << "Mismatch at array index: " << i << endl;
1391  }
1392  }
1393 
1394  if (failed)
1395  throw runtime_error(fail_msg.str());
1396 }
1397 
1398 
1399 /* Workspace method: Doxygen documentation will be auto-generated */
1400 void Compare(const ArrayOfMatrix& var1,
1401  const ArrayOfMatrix& var2,
1402  const Numeric& maxabsdiff,
1403  const String& error_message,
1404  const String& var1name,
1405  const String& var2name,
1406  const String&,
1407  const String&,
1408  const Verbosity& verbosity)
1409 {
1410  if( var1.nelem() != var2.nelem() )
1411  {
1412  ostringstream os;
1413  os << "The two arrays do not have the same size." << endl
1414  << var1name << " nelem: " << var1.nelem() << endl
1415  << var2name << " nelem: " << var2.nelem() << endl;
1416  throw runtime_error(os.str());
1417  }
1418 
1419  bool failed = false;
1420  ostringstream fail_msg;
1421  for (Index i = 0; i < var1.nelem(); i++)
1422  {
1423  try
1424  {
1425  ostringstream vn1, vn2;
1426  vn1 << var1name << "[" << i << "]";
1427  vn2 << var2name << "[" << i << "]";
1428  Compare(var1[i], var2[i], maxabsdiff, error_message,
1429  vn1.str(), vn2.str(), "", "", verbosity);
1430  }
1431  catch (runtime_error e)
1432  {
1433  failed = true;
1434  fail_msg << endl << e.what() << endl
1435  << "Mismatch at array index: " << i << endl;
1436  }
1437  }
1438 
1439  if (failed)
1440  throw runtime_error(fail_msg.str());
1441 }
1442 
1443 
1444 /* Workspace method: Doxygen documentation will be auto-generated */
1445 void Compare(const GriddedField3& var1,
1446  const GriddedField3& var2,
1447  const Numeric& maxabsdiff,
1448  const String& error_message,
1449  const String& var1name,
1450  const String& var2name,
1451  const String&,
1452  const String&,
1453  const Verbosity& verbosity)
1454 {
1455  for (Index i = 0; i < var1.get_dim(); i++)
1456  {
1457  if( var1.get_grid_size(i) != var2.get_grid_size(i) )
1458  {
1459  ostringstream os;
1460  os << var1name << " and "
1461  << var2name << " grid " << i << " do not have the same size: "
1462  << var1.get_grid_size(i) << " != " << var2.get_grid_size(i);
1463  throw runtime_error(os.str());
1464  }
1465  if( var1.get_grid_name(i) != var2.get_grid_name(i) )
1466  {
1467  ostringstream os;
1468  os << var1name << " and "
1469  << var2name << " grid " << i << " do not have the same name: "
1470  << var1.get_grid_name(i) << " != " << var2.get_grid_name(i);
1471  throw runtime_error(os.str());
1472  }
1473  }
1474 
1475  Compare(var1.data, var2.data, maxabsdiff, error_message,
1476  var1name, var2name, "", "", verbosity);
1477 }
1478 
Matrix
The Matrix class.
Definition: matpackI.h:788
gridded_fields.h
Implementation of gridded fields.
transform
void transform(VectorView y, double(&my_func)(double), ConstVectorView x)
A generic transform function for vectors, which can be used to implement mathematical functions opera...
Definition: matpackI.cc:1838
IndexStepDown
void IndexStepDown(Index &xout, const Index &xin, const Verbosity &)
WORKSPACE METHOD: IndexStepDown.
Definition: m_basic_types.cc:159
Tensor4::resize
void resize(Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackIV.cc:1403
ConstTensor7View::nshelves
Index nshelves() const
Returns the number of shelves.
Definition: matpackVII.cc:44
NumericScale
void NumericScale(Numeric &out, const Numeric &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: NumericScale.
Definition: m_basic_types.cc:405
ConstTensor6View::nshelves
Index nshelves() const
Returns the number of shelves.
Definition: matpackVI.cc:38
ConstTensor5View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackV.cc:41
exceptions.h
The declarations of all the exception classes.
ArrayOfIndexSet
void ArrayOfIndexSet(ArrayOfIndex &aoi, const ArrayOfIndex &values, const Verbosity &)
WORKSPACE METHOD: ArrayOfIndexSet.
Definition: m_basic_types.cc:75
Tensor6::resize
void resize(Index v, Index s, Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackVI.cc:2879
VectorAddScalar
void VectorAddScalar(Vector &out, const Vector &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: VectorAddScalar.
Definition: m_basic_types.cc:729
ArrayOfStringSet
void ArrayOfStringSet(ArrayOfString &sa, const ArrayOfString &sa2, const Verbosity &)
WORKSPACE METHOD: ArrayOfStringSet.
Definition: m_basic_types.cc:126
Sparse::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackII.cc:62
Matrix1RowFromVector
void Matrix1RowFromVector(Matrix &m, const Vector &v, const Verbosity &)
WORKSPACE METHOD: Matrix1RowFromVector.
Definition: m_basic_types.cc:285
Tensor3
The Tensor3 class.
Definition: matpackIII.h:348
MatrixSet
void MatrixSet(Matrix &x, const Matrix &values, const Verbosity &)
WORKSPACE METHOD: MatrixSet.
Definition: m_basic_types.cc:364
ConstTensor5View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackV.cc:59
ConstTensor6View::npages
Index npages() const
Returns the number of pages.
Definition: matpackVI.cc:50
Matrix2ColFromVectors
void Matrix2ColFromVectors(Matrix &m, const Vector &v1, const Vector &v2, const Verbosity &)
WORKSPACE METHOD: Matrix2ColFromVectors.
Definition: m_basic_types.cc:244
ConstTensor7View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackVII.cc:68
joker
const Joker joker
Sparse
The Sparse class.
Definition: matpackII.h:55
ConstTensor6View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackVI.cc:56
Vector::resize
void resize(Index n)
Resize function.
Definition: matpackI.cc:798
GriddedField::get_dim
Index get_dim() const
Get the dimension of this gridded field.
Definition: gridded_fields.h:100
Tensor4Scale
void Tensor4Scale(Tensor4 &out, const Tensor4 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor4Scale.
Definition: m_basic_types.cc:542
Tensor6SetConstant
void Tensor6SetConstant(Tensor6 &x, const Index &nvitrines, const Index &nshelves, const Index &nbooks, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor6SetConstant.
Definition: m_basic_types.cc:652
ConstMatrixView::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackI.cc:832
NumericSet
void NumericSet(Numeric &x, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: NumericSet.
Definition: m_basic_types.cc:415
Tensor7Scale
void Tensor7Scale(Tensor7 &out, const Tensor7 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor7Scale.
Definition: m_basic_types.cc:679
CREATE_OUT2
#define CREATE_OUT2
Definition: messages.h:213
Tensor3AddScalar
void Tensor3AddScalar(Tensor3 &out, const Tensor3 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor3AddScalar.
Definition: m_basic_types.cc:461
Matrix2RowFromVectors
void Matrix2RowFromVectors(Matrix &m, const Vector &v1, const Vector &v2, const Verbosity &)
WORKSPACE METHOD: Matrix2RowFromVectors.
Definition: m_basic_types.cc:299
Tensor4
The Tensor4 class.
Definition: matpackIV.h:383
array.h
This file contains the definition of Array.
NumericAdd
void NumericAdd(Numeric &out, const Numeric &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: NumericAdd.
Definition: m_basic_types.cc:385
Tensor3::resize
void resize(Index p, Index r, Index c)
Resize function.
Definition: matpackIII.cc:862
ConstTensor5View::npages
Index npages() const
Returns the number of pages.
Definition: matpackV.cc:47
VectorLogSpace
void VectorLogSpace(Vector &x, const Numeric &start, const Numeric &stop, const Numeric &step, const Verbosity &verbosity)
WORKSPACE METHOD: VectorLogSpace.
Definition: m_basic_types.cc:962
GriddedField3
Definition: gridded_fields.h:307
ConstTensor3View::npages
Index npages() const
Returns the number of pages.
Definition: matpackIII.h:143
matpackIV.h
ConstTensor7View::nlibraries
Index nlibraries() const
Returns the number of libraries.
Definition: matpackVII.cc:32
nlogspace
void nlogspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlogspace
Definition: math_funcs.cc:294
GriddedField::get_grid_size
Index get_grid_size(Index i) const
Get the size of a grid.
Definition: gridded_fields.h:120
matpackI.h
Array< Index >
IndexSet
void IndexSet(Index &x, const Index &value, const Verbosity &)
WORKSPACE METHOD: IndexSet.
Definition: m_basic_types.cc:150
Tensor4SetConstant
void Tensor4SetConstant(Tensor4 &x, const Index &nbooks, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor4SetConstant.
Definition: m_basic_types.cc:562
is_decreasing
bool is_decreasing(ConstVectorView x)
Checks if a vector is sorted in reversed order and is strictly decreasing.
Definition: logic.cc:324
get_sorted_indexes
void get_sorted_indexes(ArrayOfIndex &sorted, const T &data)
get_sorted_indexes
Definition: sorting.h:79
GriddedField3::data
Tensor3 data
Definition: gridded_fields.h:370
Tensor6Scale
void Tensor6Scale(Tensor6 &out, const Tensor6 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor6Scale.
Definition: m_basic_types.cc:631
Compare
void Compare(const Numeric &var1, const Numeric &var2, const Numeric &maxabsdiff, const String &error_message, const String &var1name, const String &var2name, const String &, const String &, const Verbosity &verbosity)
WORKSPACE METHOD: Compare.
Definition: m_basic_types.cc:1116
ConstTensor6View::nvitrines
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVI.cc:32
MatrixScale
void MatrixScale(Matrix &out, const Matrix &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixScale.
Definition: m_basic_types.cc:341
Tensor7::resize
void resize(Index l, Index v, Index s, Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackVII.cc:5379
mult
void mult(VectorView y, const ConstMatrixView &M, const ConstVectorView &x)
Matrix Vector multiplication.
Definition: matpackI.cc:1648
CREATE_OUT3
#define CREATE_OUT3
Definition: messages.h:214
Tensor5::resize
void resize(Index s, Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackV.cc:2430
NumericInvScale
void NumericInvScale(Numeric &out, const Numeric &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: NumericInvScale.
Definition: m_basic_types.cc:395
Matrix3RowFromVectors
void Matrix3RowFromVectors(Matrix &m, const Vector &v1, const Vector &v2, const Vector &v3, const Verbosity &)
WORKSPACE METHOD: Matrix3RowFromVectors.
Definition: m_basic_types.cc:319
messages.h
Declarations having to do with the four output streams.
VectorFlip
void VectorFlip(Vector &out, const Vector &in, const Verbosity &)
WORKSPACE METHOD: VectorFlip.
Definition: m_basic_types.cc:787
VectorNLinSpace
void VectorNLinSpace(Vector &x, const Index &n, const Numeric &start, const Numeric &stop, const Verbosity &verbosity)
WORKSPACE METHOD: VectorNLinSpace.
Definition: m_basic_types.cc:1014
ConstMatrixView::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackI.cc:838
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:64
abs
#define abs(x)
Definition: continua.cc:20458
VectorInsertGridPoints
void VectorInsertGridPoints(Vector &og, const Vector &ingrid, const Vector &points, const Verbosity &verbosity)
WORKSPACE METHOD: VectorInsertGridPoints.
Definition: m_basic_types.cc:811
ConstVectorView::nelem
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:180
StringSet
void StringSet(String &s, const String &s2, const Verbosity &)
WORKSPACE METHOD: StringSet.
Definition: m_basic_types.cc:452
ConstTensor7View::nvitrines
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVII.cc:38
ConstTensor4View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackIV.cc:81
Tensor3SetConstant
void Tensor3SetConstant(Tensor3 &x, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor3SetConstant.
Definition: m_basic_types.cc:501
ConstTensor7View::npages
Index npages() const
Returns the number of pages.
Definition: matpackVII.cc:56
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
Verbosity
Definition: messages.h:50
VectorCrop
void VectorCrop(Vector &out, const Vector &in, const Numeric &min_value, const Numeric &max_value, const Verbosity &)
WORKSPACE METHOD: VectorCrop.
Definition: m_basic_types.cc:752
ConstTensor4View::npages
Index npages() const
Returns the number of pages.
Definition: matpackIV.cc:69
matpackIII.h
ConstTensor4View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackIV.cc:63
math_funcs.h
make_array.h
Implements the class MakeArray, which is a derived class of Array, allowing explicit initialization.
Tensor5SetConstant
void Tensor5SetConstant(Tensor5 &x, const Index &nshelves, const Index &nbooks, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor5SetConstant.
Definition: m_basic_types.cc:606
IndexStepUp
void IndexStepUp(Index &xout, const Index &xin, const Verbosity &)
WORKSPACE METHOD: IndexStepUp.
Definition: m_basic_types.cc:168
ArrayOfIndexLinSpace
void ArrayOfIndexLinSpace(ArrayOfIndex &x, const Index &start, const Index &stop, const Index &step, const Verbosity &verbosity)
WORKSPACE METHOD: ArrayOfIndexLinSpace.
Definition: m_basic_types.cc:96
SparseSparseMultiply
void SparseSparseMultiply(Sparse &Y, const Sparse &M, const Sparse &X, const Verbosity &)
WORKSPACE METHOD: SparseSparseMultiply.
Definition: m_basic_types.cc:424
Matrix::resize
void resize(Index r, Index c)
Resize function.
Definition: matpackI.cc:1580
VectorScale
void VectorScale(Vector &out, const Vector &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: VectorScale.
Definition: m_basic_types.cc:1066
ConstTensor3View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackIII.h:146
VectorLinSpace
void VectorLinSpace(Vector &x, const Numeric &start, const Numeric &stop, const Numeric &step, const Verbosity &verbosity)
WORKSPACE METHOD: VectorLinSpace.
Definition: m_basic_types.cc:939
nlinspace
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
Definition: math_funcs.cc:261
ConstTensor6View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackVI.cc:44
Tensor5
The Tensor5 class.
Definition: matpackV.h:451
ConstTensor4View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackIV.cc:75
MatrixSetConstant
void MatrixSetConstant(Matrix &x, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixSetConstant.
Definition: m_basic_types.cc:373
Range
The range class.
Definition: matpackI.h:148
ArrayOfIndexSetConstant
void ArrayOfIndexSetConstant(ArrayOfIndex &aoi, const Index &nelem, const Index &value, const Verbosity &)
WORKSPACE METHOD: ArrayOfIndexSetConstant.
Definition: m_basic_types.cc:84
Matrix1ColFromVector
void Matrix1ColFromVector(Matrix &m, const Vector &v, const Verbosity &)
WORKSPACE METHOD: Matrix1ColFromVector.
Definition: m_basic_types.cc:230
ConstTensor7View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackVII.cc:50
ConstTensor5View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackV.cc:53
VectorSet
void VectorSet(Vector &x, const Vector &values, const Verbosity &)
WORKSPACE METHOD: VectorSet.
Definition: m_basic_types.cc:1107
matpackV.h
is_increasing
bool is_increasing(ConstVectorView x)
Checks if a vector is sorted and strictly increasing.
Definition: logic.cc:275
logic.h
Header file for logic.cc.
Sparse::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackII.cc:56
ConstTensor5View::nshelves
Index nshelves() const
Returns the number of shelves.
Definition: matpackV.cc:35
ConstTensor3View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackIII.h:149
matpackII.h
Header file for sparse matrices.
VectorNLogSpace
void VectorNLogSpace(Vector &x, const Index &n, const Numeric &start, const Numeric &stop, const Verbosity &verbosity)
WORKSPACE METHOD: VectorNLogSpace.
Definition: m_basic_types.cc:1040
Matrix3ColFromVectors
void Matrix3ColFromVectors(Matrix &m, const Vector &v1, const Vector &v2, const Vector &v3, const Verbosity &)
WORKSPACE METHOD: Matrix3ColFromVectors.
Definition: m_basic_types.cc:264
FlagOn
void FlagOn(Index &x, const Verbosity &)
WORKSPACE METHOD: FlagOn.
Definition: m_basic_types.cc:143
VectorMatrixMultiply
void VectorMatrixMultiply(Vector &y, const Matrix &M, const Vector &x, const Verbosity &)
WORKSPACE METHOD: VectorMatrixMultiply.
Definition: m_basic_types.cc:986
MatrixMatrixMultiply
void MatrixMatrixMultiply(Matrix &Y, const Matrix &M, const Matrix &X, const Verbosity &)
WORKSPACE METHOD: MatrixMatrixMultiply.
Definition: m_basic_types.cc:200
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
GriddedField::get_grid_name
const String & get_grid_name(Index i) const
Get grid name.
Definition: gridded_fields.h:111
ConstTensor7View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackVII.cc:62
linspace
void linspace(Vector &x, const Numeric start, const Numeric stop, const Numeric step)
linspace
Definition: math_funcs.cc:228
arts_exit
void arts_exit(int status)
This is the exit function of ARTS.
Definition: arts.cc:42
Tensor6
The Tensor6 class.
Definition: matpackVI.h:950
M
#define M
Definition: rng.cc:196
Vector
The Vector class.
Definition: matpackI.h:556
FlagOff
void FlagOff(Index &x, const Verbosity &)
WORKSPACE METHOD: FlagOff.
Definition: m_basic_types.cc:136
sorting.h
Contains sorting routines.
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:176
Tensor7SetConstant
void Tensor7SetConstant(Tensor7 &x, const Index &nlibraries, const Index &nvitrines, const Index &nshelves, const Index &nbooks, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor7SetConstant.
Definition: m_basic_types.cc:700
ConstTensor6View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackVI.cc:62
MatrixAddScalar
void MatrixAddScalar(Matrix &out, const Matrix &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixAddScalar.
Definition: m_basic_types.cc:177
Tensor5Scale
void Tensor5Scale(Tensor5 &out, const Tensor5 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor5Scale.
Definition: m_basic_types.cc:585
matpackVI.h
mystring.h
This file contains the definition of String, the ARTS string class.
Tensor7
The Tensor7 class.
Definition: matpackVII.h:1931
matpackVII.h
arts.h
The global header file for ARTS.
Tensor4AddScalar
void Tensor4AddScalar(Tensor4 &out, const Tensor4 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor4AddScalar.
Definition: m_basic_types.cc:522
Tensor3Scale
void Tensor3Scale(Tensor3 &out, const Tensor3 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor3Scale.
Definition: m_basic_types.cc:481
VectorSetConstant
void VectorSetConstant(Vector &x, const Index &n, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: VectorSetConstant.
Definition: m_basic_types.cc:1089