ARTS 2.5.0 (git: 9ee3ac6c)
matpack_complex.h
Go to the documentation of this file.
1/* Copyright (C) 2002-2012 Stefan Buehler <sbuehler@ltu.se>
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 USA. */
17
26#ifndef matpack_complex_h
27#define matpack_complex_h
28
29#include "lapack.h"
30#include "matpackI.h"
31#include "nonstd.h"
32#include <complex>
33#include <utility>
34
35using Complex = std::complex<Numeric>;
37
39inline Numeric& real_val(Complex& c) noexcept {return reinterpret_cast<ComplexLayout(&)>(c).real;}
40
42inline Numeric& imag_val(Complex& c) noexcept {return reinterpret_cast<ComplexLayout(&)>(c).imag;}
43
45inline const Numeric& real_val(const Complex& c) noexcept {return reinterpret_cast<const ComplexLayout(&)>(c).real;}
46
48inline const Numeric& imag_val(const Complex& c) noexcept {return reinterpret_cast<const ComplexLayout(&)>(c).imag;}
49
50inline std::complex<float> operator+(const double& d,
51 const std::complex<float>& c) {
52 return (float(d) + c);
53}
54inline std::complex<float> operator*(const double& d,
55 const std::complex<float>& c) {
56 return (float(d) * c);
57}
58
59inline std::complex<float> operator+(const std::complex<float>& c,
60 const double& d) {
61 return (c + float(d));
62}
63inline std::complex<float> operator*(const std::complex<float>& c,
64 const double& d) {
65 return (c * float(d));
66}
67
68// Constexpr versions of common Complex operations
69
70// Helpers to keep equations readable
71#define a1 c.real()
72#define b1 c.imag()
73#define a2 z.real()
74#define b2 z.imag()
75
77constexpr Numeric abs2(Complex c) noexcept { return a1 * a1 + b1 * b1; }
78
80constexpr Complex conj(Complex c) noexcept { return Complex(a1, -b1); }
81
83constexpr Numeric real(Complex c) noexcept { return a1; }
84
86constexpr Numeric imag(Complex c) noexcept { return b1; }
87
88// Basic constexpr operations for Complex that don't exist in the standard yet (C++11)
89// NOTE: Remove these if there is ever an overload warning updating the C++ compiler version
90
91constexpr Complex operator+(Complex c, Numeric n) noexcept {
92 return Complex(a1 + n, b1);
93}
94constexpr Complex operator-(Complex c, Numeric n) noexcept {
95 return Complex(a1 - n, b1);
96}
97constexpr Complex operator*(Complex c, Numeric n) noexcept {
98 return Complex(a1 * n, b1 * n);
99}
100constexpr Complex operator/(Complex c, Numeric n) noexcept {
101 return Complex(a1 / n, b1 / n);
102}
103
104constexpr Complex operator+(Numeric n, Complex c) noexcept {
105 return Complex(n + a1, b1);
106}
107constexpr Complex operator-(Numeric n, Complex c) noexcept {
108 return Complex(n - a1, -b1);
109}
110constexpr Complex operator*(Numeric n, Complex c) noexcept {
111 return Complex(n * a1, n * b1);
112}
113constexpr Complex operator/(Numeric n, Complex c) noexcept {
114 return Complex(n * a1, -n * b1) / abs2(c);
115}
116
117constexpr Complex operator+(Complex c, Complex z) noexcept {
118 return Complex(a1 + a2, b1 + b2);
119}
120constexpr Complex operator-(Complex c, Complex z) noexcept {
121 return Complex(a1 - a2, b1 - b2);
122}
123constexpr Complex operator*(Complex c, Complex z) noexcept {
124 return Complex(a1 * a2 - b1 * b2, a1 * b2 + b1 * a2);
125}
126constexpr Complex operator/(Complex c, Complex z) noexcept {
127 return Complex(a1 * a2 + b1 * b2, -a1 * b2 + b1 * a2) / abs2(z);
128}
129constexpr Complex operator-(Complex c) noexcept { return Complex(-a1, -b1); }
130
131// Remove helpers to keep global namespace usable
132#undef a1
133#undef b1
134#undef a2
135#undef b2
136
137// Basic constexpr operations for different types since C++11 std::complex is lacking conversions
138// FIXME: Cannot be template because Eigen interferes, so explicit copies are required for operations
139// NOTE: Remove these if there is ever an overload warning updating the C++ compiler version
140#define _complex_operations_(T) \
141 constexpr Complex operator+(Complex c, T x) noexcept { \
142 return operator+(c, static_cast<Numeric>(x)); \
143 } \
144 constexpr Complex operator-(Complex c, T x) noexcept { \
145 return operator-(c, static_cast<Numeric>(x)); \
146 } \
147 constexpr Complex operator*(Complex c, T x) noexcept { \
148 return operator*(c, static_cast<Numeric>(x)); \
149 } \
150 constexpr Complex operator/(Complex c, T x) noexcept { \
151 return operator/(c, static_cast<Numeric>(x)); \
152 } \
153 \
154 constexpr Complex operator+(T x, Complex c) noexcept { \
155 return operator+(static_cast<Numeric>(x), c); \
156 } \
157 constexpr Complex operator-(T x, Complex c) noexcept { \
158 return operator-(static_cast<Numeric>(x), c); \
159 } \
160 constexpr Complex operator*(T x, Complex c) noexcept { \
161 return operator*(static_cast<Numeric>(x), c); \
162 } \
163 constexpr Complex operator/(T x, Complex c) noexcept { \
164 return operator/(static_cast<Numeric>(x), c); \
165 }
166
170
171#undef _complex_operations_
172
173constexpr bool isnan(Complex c) noexcept {
174 return nonstd::isnan(c.real()) or nonstd::isnan(c.imag());
175}
176
177 // Declare existence of the global joker object:
178 extern const Joker joker;
179
180// Declare the existence of class ConstComplexMatrixView:
182
183// Declare the existence of class ComplexVectorView:
185
186// Declare the existence of class ConstComplexVectorView:
188
189// Declare the existence of class ConstMatrixView:
191
192// Eigen library interactions:
193using ComplexMatrixType = Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
194using ComplexMatrixViewMap = Eigen::Map<ComplexMatrixType, 0, StrideType>;
195using ConstComplexMatrixViewMap = Eigen::Map<const ComplexMatrixType, 0, StrideType>;
196
200 public:
202 ComplexIterator1D() = default;
203
206 : mx(x), mstride(stride) { /* Nothing to do here. */
207 }
208
209 // Operators:
210
213 mx += mstride;
214 return *this;
215 }
216
218 Complex& operator*() const { return *mx; }
219
221 bool operator!=(const ComplexIterator1D& other) const {
222 if (mx != other.mx)
223 return true;
224 return false;
225 }
226
227 friend void copy(ConstComplexIterator1D origin,
229 ComplexIterator1D target);
230
231 private:
233 Complex* mx{nullptr};
236};
237
241 public:
244
247 : mx(x), mstride(stride) { /* Nothing to do here. */
248 }
249
250 // Operators:
253 mx += mstride;
254 return *this;
255 }
256
258 const Complex& operator*() const { return *mx; }
259
261 bool operator!=(const ConstComplexIterator1D& other) const {
262 if (mx != other.mx)
263 return true;
264 return false;
265 }
266
267 friend void copy(ConstComplexIterator1D origin,
269 ComplexIterator1D target);
270
271 private:
273 const Complex* mx{nullptr};
276};
277
278// Declare the complex vector class:
279class ComplexVector;
280
281// Declare the ComplexMatrixView class
283
290 public:
295
296 // Typedef for compatibility with STL
298
299 // Member functions:
300 [[nodiscard]] bool empty() const noexcept { return (nelem() == 0); }
301 [[nodiscard]] Index nelem() const noexcept { return mrange.mextent; }
302 [[nodiscard]] Complex sum() const;
303
304 // Const index operators:
306 const Complex& operator[](Index n) const { // Check if index is valid:
307 ARTS_ASSERT(0 <= n);
309 return get(n);
310 }
311
313 [[nodiscard]] const Complex& get(Index n) const {
314 return *(mdata + mrange.mstart + n * mrange.mstride);
315 }
316
318 [[nodiscard]] const Numeric& get_real(Index n) const {
319 return reinterpret_cast<const ComplexLayout(&)>(get(n)).real;
320 }
321
323 [[nodiscard]] const Numeric& get_imag(Index n) const {
324 return reinterpret_cast<const ComplexLayout(&)>(get(n)).imag;
325 }
326
328 [[nodiscard]] ConstVectorView real() const {return ConstVectorView(reinterpret_cast<Numeric *>(mdata), Range(2*mrange.mstart, mrange.mextent, mrange.mstride*2));}
329
331 [[nodiscard]] ConstVectorView imag() const {return ConstVectorView(reinterpret_cast<Numeric *>(mdata), Range(2*mrange.mstart + 1, mrange.mextent, mrange.mstride*2));}
332
336
337 // Functions returning iterators:
338 [[nodiscard]] ConstComplexIterator1D begin() const;
339 [[nodiscard]] ConstComplexIterator1D end() const;
340
341 // Conversion to 1 column matrix:
342 operator ConstComplexMatrixView() const;
343
345 virtual ~ConstComplexVectorView() = default;
346
347 // Friends:
348 friend class ComplexVectorView;
351 friend void mult(ComplexVectorView,
354
359
360 // A special constructor, that allows to make a ConstVectorView of a scalar.
362
363 protected:
364 // Constructors:
367 ConstComplexVectorView(Complex* data, const Range& p, const Range& n);
368
369 // Data members:
370 // -------------
374 Complex* mdata{nullptr};
375};
376
389 public:
390 // Make const methods visible from base class
393 using ConstComplexVectorView::operator[];
399
400 constexpr ComplexVectorView(const ComplexVectorView&) = default;
403
404 // Typedef for compatibility with STL
406
408 Complex& operator[](Index n) { // Check if index is valid:
409 ARTS_ASSERT(0 <= n);
411 return get(n);
412 }
413
416 return *(mdata + mrange.mstart + n * mrange.mstride);
417 }
418
421 return reinterpret_cast<ComplexLayout(&)>(get(n)).real;
422 }
423
426 return reinterpret_cast<ComplexLayout(&)>(get(n)).imag;
427 }
428
431
433 VectorView imag() {return VectorView(reinterpret_cast<Numeric *>(mdata), Range(2*mrange.mstart + 1, mrange.mextent, mrange.mstride*2));}
434
436
437 // ComplexIterators:
440
441 // Assignment operators:
452
453 // Other operators:
462
471
472 // Conversion to 1 column matrix:
473 operator ComplexMatrixView();
474 // Conversion to a plain C-array
475 [[nodiscard]] const Complex* get_c_array() const ARTS_NOEXCEPT;
477
479 ~ComplexVectorView() override = default;
480
481 // Friends:
483 friend class ComplexIterator2D;
484 friend class ComplexMatrixView;
485
486 // A special constructor, that allows to make a ComplexVectorView of a scalar.
488
489 protected:
490 // Constructors:
491 ComplexVectorView() = default;
492 ComplexVectorView(Complex* data, const Range& range);
493 ComplexVectorView(Complex* data, const Range& p, const Range& n);
494};
495
500 public:
501 // Constructors:
503 ComplexIterator2D() = default;
504
507 : msv(x), mstride(stride) { /* Nothing to do here. */
508 }
509
510 // Operators:
513 msv.mdata += mstride;
514 return *this;
515 }
516
518 bool operator!=(const ComplexIterator2D& other) const {
519 if (msv.mdata + msv.mrange.mstart !=
520 other.msv.mdata + other.msv.mrange.mstart)
521 return true;
522 return false;
523 }
524
527 ComplexVectorView* operator->() { return &msv; }
528
530 ComplexVectorView& operator*() { return msv; }
531
532 private:
536 Index mstride{0};
537};
538
543 public:
544 // Constructors:
547
550 : msv(std::move(x)), mstride(stride) { /* Nothing to do here. */
551 }
552
553 // Operators:
556 msv.mdata += mstride;
557 return *this;
558 }
559
561 bool operator!=(const ConstComplexIterator2D& other) const {
562 if (msv.mdata + msv.mrange.mstart !=
563 other.msv.mdata + other.msv.mrange.mstart)
564 return true;
565 return false;
566 }
567
570 const ConstComplexVectorView* operator->() const { return &msv; }
571
573 const ConstComplexVectorView& operator*() const { return msv; }
574
575 private:
579 Index mstride{0};
580};
581
593 public:
594 // Constructors:
596 explicit ComplexVector(Index n);
597 ComplexVector(Index n, Complex fill);
598 ComplexVector(Index n, Numeric fill);
599 ComplexVector(Complex start, Index extent, Complex stride);
600 ComplexVector(Complex start, Index extent, Numeric stride);
601 ComplexVector(Numeric start, Index extent, Complex stride);
602 ComplexVector(Numeric start, Index extent, Numeric stride);
605 ComplexVector(const Vector& v);
606 ComplexVector(const std::vector<Complex>&);
607 ComplexVector(const std::vector<Numeric>&);
610 ARTS_ASSERT(r0.get_extent() >= 0, "Must have size. Has: ", r0.get_extent());
611 }
612
613 // Assignment operators:
617
618 // Resize function:
619 void resize(Index n);
620
621 // Swap function:
622 friend void swap(ComplexVector& v1, ComplexVector& v2);
623
624 // Destructor:
625 ~ComplexVector() override;
626
627 // Total size
628 [[nodiscard]] Index size() const noexcept {return nelem();}
629};
630
631// Declare class ComplexMatrix:
632class ComplexMatrix;
633
645 public:
650
651 // Typedef for compatibility with STL
653
654 // Member functions:
655 [[nodiscard]] Index nrows() const noexcept { return mrr.mextent; }
656 [[nodiscard]] Index ncols() const noexcept { return mcr.mextent; }
657 [[nodiscard]] bool empty() const noexcept { return not nrows() or not ncols(); }
658
659 // Const index operators:
661 Complex operator()(Index r, Index c) const { // Check if indices are valid:
662 ARTS_ASSERT(0 <= r);
663 ARTS_ASSERT(0 <= c);
664 ARTS_ASSERT(r < mrr.mextent);
665 ARTS_ASSERT(c < mcr.mextent);
666
667 return get(r, c);
668 }
669
671 [[nodiscard]] Complex get(Index r, Index c) const {
672 return *(mdata + mrr.mstart + r * mrr.mstride + mcr.mstart +
673 c * mcr.mstride);
674 }
675
677 [[nodiscard]] Numeric get_real(Index r, Index c) const { return get(r, c).real(); }
678
680 [[nodiscard]] Numeric get_imag(Index r, Index c) const { return get(r, c).imag(); }
681
683 [[nodiscard]] ConstMatrixView real() const {return ConstMatrixView(reinterpret_cast<Numeric *>(mdata), Range(2*mrr.mstart, mrr.mextent, mrr.mstride*2),
684 Range(2*mcr.mstart, mcr.mextent, mcr.mstride*2));}
685
687 [[nodiscard]] ConstMatrixView imag() const {return ConstMatrixView(reinterpret_cast<Numeric *>(mdata), Range(2*mrr.mstart, mrr.mextent, mrr.mstride*2),
688 Range(2*mcr.mstart + 1, mcr.mextent, mcr.mstride*2));}
689
691 [[nodiscard]] Index get_column_extent() const {return mcr.get_extent();}
692
693 ConstComplexMatrixView operator()(const Range& r, const Range& c) const;
694 ConstComplexVectorView operator()(const Range& r, Index c) const;
695 ConstComplexVectorView operator()(Index r, const Range& c) const;
696
697 // Functions returning iterators:
698 [[nodiscard]] ConstComplexIterator2D begin() const;
699 [[nodiscard]] ConstComplexIterator2D end() const;
700
701 // View on diagonal complex vector
702 [[nodiscard]] ConstComplexVectorView diagonal() const;
703
705 virtual ~ConstComplexMatrixView() = default;
706
707 // Friends:
708 friend class ComplexMatrixView;
711 friend void mult(ComplexVectorView,
714 friend void mult(ComplexMatrixView,
717 friend void mult(ComplexMatrixView,
718 const ConstMatrixView&,
720 friend void mult(ComplexMatrixView,
722 const ConstMatrixView&);
723
724
727
728 protected:
729 // Constructors:
731 ConstComplexMatrixView(Complex* data, const Range& r, const Range& c);
733 const Range& pr,
734 const Range& pc,
735 const Range& nr,
736 const Range& nc);
737
738 // Data members:
739 // -------------
741 Range mrr{0, 0, 1};
743 Range mcr{0, 0, 1};
745 Complex* mdata{nullptr};
746};
747
758 public:
759 // Make const methods visible from base class
762 using ConstComplexMatrixView::operator();
769
770 constexpr ComplexMatrixView(const ComplexMatrixView&) = default;
771
772 // Typedef for compatibility with STL
774
775 // Index Operators:
777 Complex& operator()(Index r, Index c) { // Check if indices are valid:
778 ARTS_ASSERT(0 <= r);
779 ARTS_ASSERT(0 <= c);
780 ARTS_ASSERT(r < mrr.mextent);
781 ARTS_ASSERT(c < mcr.mextent);
782
783 return get(r, c);
784 }
785
788 return *(mdata + mrr.mstart + r * mrr.mstride + mcr.mstart +
789 c * mcr.mstride);
790 }
791
794 return reinterpret_cast<ComplexLayout(&)>(get(r, c)).real;
795 }
796
799 return reinterpret_cast<ComplexLayout(&)>(get(r, c)).imag;
800 }
801
803 MatrixView real() {return MatrixView(reinterpret_cast<Numeric *>(mdata), Range(2*mrr.mstart, mrr.mextent, mrr.mstride*2),
804 Range(2*mcr.mstart, mcr.mextent, mcr.mstride*2));}
805
807 MatrixView imag() {return MatrixView(reinterpret_cast<Numeric *>(mdata), Range(2*mrr.mstart, mrr.mextent, mrr.mstride*2),
808 Range(2*mcr.mstart + 1, mcr.mextent, mcr.mstride*2));}
809
810 ComplexMatrixView operator()(const Range& r, const Range& c);
811 ComplexVectorView operator()(const Range& r, Index c);
812 ComplexVectorView operator()(Index r, const Range& c);
813
814 // Functions returning iterators:
817
818 // View on diagonal complex vector
819 ComplexVectorView diagonal();
820
821 // Assignment operators:
827
828 // Other operators:
837
842
847
852
853 // Conversion to a plain C-array
854 [[nodiscard]] const Complex* get_c_array() const ARTS_NOEXCEPT;
856
858 ~ComplexMatrixView() override = default;
859
860 // Friends:
861 friend class ComplexVectorView;
864
865 protected:
866 // Constructors:
868 ComplexMatrixView(Complex* data, const Range& r, const Range& c);
870 const Range& pr,
871 const Range& pc,
872 const Range& nr,
873 const Range& nc);
874};
875
885 public:
886 // Constructors:
887 ComplexMatrix() = default;
893
894 // Assignment operators:
898
899 // Inverse in place
901
902 // Resize function:
903 void resize(Index r, Index c);
904
905 // Swap function:
906 friend void swap(ComplexMatrix& m1, ComplexMatrix& m2);
907
908 // Destructor:
909 ~ComplexMatrix() override;
910
911 // Total size
912 [[nodiscard]] Index size() const noexcept {return nrows() * ncols();}
913
915};
916
917// Function declarations:
918// ----------------------
919
921
923
924void copy(ConstComplexIterator1D origin,
926 ComplexIterator1D target);
927
928void copy(Complex x, ComplexIterator1D target, const ComplexIterator1D& end);
929
930void copy(ConstComplexIterator2D origin,
932 ComplexIterator2D target);
933
934void copy(Complex x, ComplexIterator2D target, const ComplexIterator2D& end);
935
938 const ConstComplexVectorView& x);
939
941 const ConstComplexMatrixView& B,
942 const ConstComplexMatrixView& C);
944 const ConstMatrixView& B,
945 const ConstComplexMatrixView& C);
947 const ConstComplexMatrixView& B,
948 const ConstMatrixView& C);
950 const ConstMatrixView& B,
951 const ConstMatrixView& C);
952
955
956std::ostream& operator<<(std::ostream& os, const ConstComplexVectorView& v);
957
958std::ostream& operator<<(std::ostream& os, const ConstComplexMatrixView& v);
959
960// Converts constant matrix to constant eigen map
962// Converts constant vector to constant eigen row-view
964// Converts constant vector to constant eigen row-view
966// Converts constant vector to constant eigen column-view
968// Converts matrix to eigen map
970// Converts vector to eigen map row-view
972// Converts vector to eigen map row-view
974// Converts vector to eigen map column-view
976
979
980#endif
Index nrows
void * data
Index ncols
This can be used to make arrays out of anything.
Definition: array.h:107
The iterator class for sub vectors.
ComplexIterator1D & operator++()
Prefix increment operator.
bool operator!=(const ComplexIterator1D &other) const
Not equal operator, needed for algorithms like copy.
ComplexIterator1D()=default
Default constructor.
ComplexIterator1D(Complex *x, Index stride)
Explicit constructor.
Index mstride
Stride.
Complex & operator*() const
Dereferencing.
Complex * mx
Current position.
friend void copy(ConstComplexIterator1D origin, const ConstComplexIterator1D &end, ComplexIterator1D target)
Copy data between begin and end to target.
The row iterator class for sub matrices.
ComplexIterator2D & operator++()
Prefix increment operator.
ComplexVectorView & operator*()
Dereferencing.
ComplexVectorView msv
Current position.
ComplexVectorView * operator->()
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
bool operator!=(const ComplexIterator2D &other) const
Not equal operator, needed for algorithms like copy.
ComplexIterator2D(const ComplexVectorView &x, Index stride)
Explicit constructor.
ComplexIterator2D()=default
Default constructor.
The ComplexMatrixView class.
ComplexMatrixView & operator-=(const ConstComplexVectorView &x)
ComplexMatrixView & operator*=(const ConstComplexVectorView &x)
Complex & operator()(Index r, Index c)
Plain index operator.
MatrixView imag()
Get a view of the imaginary parts of the matrix.
MatrixView real()
Get a view of the real part of the matrix.
ComplexMatrixView & operator+=(const ConstComplexVectorView &x)
Numeric & get_imag(Index r, Index c)
Get element implementation without assertions.
Complex & get(Index r, Index c)
Get element implementation without assertions.
constexpr ComplexMatrixView(const ComplexMatrixView &)=default
Numeric & get_real(Index r, Index c)
Get element implementation without assertions.
ComplexMatrixView & operator/=(const ConstComplexVectorView &x)
The ComplexMatrix class.
Complex * get_raw_data()
ComplexMatrix()=default
Index size() const noexcept
The ComplexVectorView class.
ComplexVectorView & operator=(const Vector &v)
VectorView real()
Get a view of the real part of the vector.
ComplexVectorView & operator=(const Array< Numeric > &v)
ComplexVectorView operator-=(Complex x)
Subtraction of scalar.
ComplexVectorView & operator=(const VectorView &v)
Numeric & get_real(Index n)
Get element implementation without assertions.
friend class ConstComplexIterator2D
constexpr ComplexVectorView(const ComplexVectorView &)=default
ComplexVectorView & operator=(Numeric x)
ComplexVectorView operator+=(Complex x)
Addition of scalar.
VectorView imag()
Get a view of the imaginary part of the vector.
ComplexVectorView operator*=(Complex x)
Multiplication by scalar.
ComplexVectorView & operator=(const ConstComplexVectorView &v)
Assignment operator.
ComplexVectorView()=default
ComplexIterator1D end()
Return iterator behind last element.
ComplexVectorView & operator=(const ConstVectorView &v)
Complex & operator[](Index n)
Plain Index operator.
friend class ComplexIterator2D
ComplexVectorView operator/=(Complex x)
Division by scalar.
const Complex * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
Complex & get(Index n)
Get element implementation without assertions.
Numeric & get_imag(Index n)
Get element implementation without assertions.
ComplexIterator1D begin()
Return iterator to first element.
friend class ComplexMatrixView
The ComplexVector class.
ComplexVector()
Default constructor.
Index size() const noexcept
ComplexVector(Complex *c, const Range &r0) ARTS_NOEXCEPT
The constant iterator class for sub vectors.
ConstComplexIterator1D()=default
Default constructor.
const Complex & operator*() const
Dereferencing.
ConstComplexIterator1D & operator++()
Prefix increment operator.
const Complex * mx
Current position.
bool operator!=(const ConstComplexIterator1D &other) const
Not equal operator, needed for algorithms like copy.
friend void copy(ConstComplexIterator1D origin, const ConstComplexIterator1D &end, ComplexIterator1D target)
Copy data between begin and end to target.
ConstComplexIterator1D(Complex *x, Index stride)
Explicit constructor.
The const row iterator class for sub matrices.
bool operator!=(const ConstComplexIterator2D &other) const
Not equal operator, needed for algorithms like copy.
ConstComplexIterator2D(ConstComplexVectorView x, Index stride)
Explicit constructor.
ConstComplexIterator2D & operator++()
Prefix increment operator.
const ConstComplexVectorView & operator*() const
Dereferencing.
ConstComplexIterator2D()=default
Default constructor.
const ConstComplexVectorView * operator->() const
The -> operator is needed, so that we can write i->begin() to get t he 1D iterators.
ConstComplexVectorView msv
Current position.
A constant view of a ComplexMatrix.
Complex get(Index r, Index c) const
Get element implementation without assertions.
ConstComplexIterator2D begin() const
Return const iterator to first row.
constexpr ConstComplexMatrixView(const ConstComplexMatrixView &)=default
ConstComplexVectorView diagonal() const
ComplexMatrix diagonal as vector.
bool empty() const noexcept
Complex operator()(Index r, Index c) const
Plain const index operator.
Numeric get_imag(Index r, Index c) const
Get element implementation without assertions.
Index ncols() const noexcept
ConstComplexMatrixView()=default
ConstComplexMatrixView & operator=(ConstComplexMatrixView &&)=default
Index nrows() const noexcept
Index get_column_extent() const
Get the extent of the underlying data.
ConstMatrixView imag() const
Get a view of the imaginary part of the matrix.
ConstComplexMatrixView & operator=(const ConstComplexMatrixView &)=default
constexpr ConstComplexMatrixView(ConstComplexMatrixView &&)=default
ConstComplexIterator2D end() const
Return const iterator behind last row.
virtual ~ConstComplexMatrixView()=default
Destructor.
Numeric get_real(Index r, Index c) const
Get element implementation without assertions.
ConstMatrixView real() const
Get a view of the real part of the matrix.
A constant view of a ComplexVector.
Complex sum() const
Returns true if variable size is zero.
ConstVectorView imag() const
Get a view of the imaginary part of the vector.
bool empty() const noexcept
const Numeric & get_imag(Index n) const
Get element implementation without assertions.
ConstComplexIterator1D end() const
Return const iterator behind last element.
friend class ConstComplexMatrixView
ConstComplexVectorView & operator=(ConstComplexVectorView &&)=default
ConstVectorView real() const
Get a view of the real part of the vector.
friend ConstComplexMatrixViewMap MapToEigen(const ConstComplexVectorView &)
Range mrange
The range of mdata that is actually used.
ConstComplexVectorView()=default
constexpr ConstComplexVectorView(ConstComplexVectorView &&)=default
Complex * mdata
Pointer to the plain C array that holds the data.
ConstComplexIterator1D begin() const
Return const iterator to first element.
friend Complex operator*(const ConstComplexVectorView &a, const ConstComplexVectorView &b)
Scalar product.
const Numeric & get_real(Index n) const
Get element implementation without assertions.
const Complex & get(Index n) const
Get element implementation without assertions.
constexpr ConstComplexVectorView(const ConstComplexVectorView &)=default
Index nelem() const noexcept
friend ConstComplexMatrixViewMap MapToEigenCol(const ConstComplexVectorView &)
const Complex & operator[](Index n) const
Plain const index operator.
virtual ~ConstComplexVectorView()=default
Destructor.
ConstComplexVectorView & operator=(const ConstComplexVectorView &)=default
friend void mult(ComplexVectorView, const ConstComplexMatrixView &, const ConstComplexVectorView &)
Matrix-Vector Multiplication.
A constant view of a Matrix.
Definition: matpackI.h:1014
A constant view of a Vector.
Definition: matpackI.h:489
The Joker class.
Definition: matpackI.h:131
The MatrixView class.
Definition: matpackI.h:1125
The range class.
Definition: matpackI.h:165
Index mstart
The start index.
Definition: matpackI.h:351
Index mstride
The stride.
Definition: matpackI.h:360
Index mextent
The number of elements.
Definition: matpackI.h:358
The VectorView class.
Definition: matpackI.h:626
The Vector class.
Definition: matpackI.h:876
#define ARTS_NOEXCEPT
Definition: debug.h:80
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
Interface for the LAPACK library.
void inv(MatrixView Ainv, ConstMatrixView A)
Matrix Inverse.
Definition: lin_alg.cc:167
Implementation of Matrix, Vector, and such stuff.
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
void swap(ComplexVector &v1, ComplexVector &v2)
Swaps two objects.
#define _complex_operations_(T)
ConstComplexMatrixView transpose(ConstComplexMatrixView m)
Const version of transpose.
std::complex< float > operator+(const double &d, const std::complex< float > &c)
#define b1
std::complex< float > operator*(const double &d, const std::complex< float > &c)
Numeric & real_val(Complex &c) noexcept
Return a reference to the real value of c.
constexpr Numeric imag(Complex c) noexcept
imag
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ComplexMatrixType
const Joker joker
constexpr Complex conj(Complex c) noexcept
the conjugate of c
#define a2
Numeric & imag_val(Complex &c) noexcept
Return a reference to the imaginary value of c.
constexpr Numeric abs2(Complex c) noexcept
squared magnitude of c
std::ostream & operator<<(std::ostream &os, const ConstComplexVectorView &v)
Output operator.
#define a1
ConstComplexMatrixViewMap MapToEigenRow(const ConstComplexVectorView &A)
std::complex< Numeric > Complex
constexpr Complex operator/(Complex c, Numeric n) noexcept
constexpr Complex operator-(Complex c, Numeric n) noexcept
#define b2
constexpr Numeric real(Complex c) noexcept
real
void copy(ConstComplexIterator1D origin, const ConstComplexIterator1D &end, ComplexIterator1D target)
Copy data between begin and end to target.
Eigen::Map< const ComplexMatrixType, 0, StrideType > ConstComplexMatrixViewMap
Eigen::Map< ComplexMatrixType, 0, StrideType > ComplexMatrixViewMap
constexpr Numeric r0
The reference radius in IGRF13.
Definition: igrf13.cc:203
VectorView std(VectorView std, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the standard deviation of the ranged ys.
Definition: raw.cc:205
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:78
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:109
constexpr bool isnan(double d) noexcept
Definition: nonstd.h:39
#define d
#define v
#define a
#define c
#define b
#define M
Definition: rng.cc:165
Struct cannot be const, but can be passed as const to allow defaults.
Definition: lapack.h:23