specmat.h
Go to the documentation of this file.
#ifndef SPECMAT_H
#define SPECMAT_H
#include <itpp/base/vec.h>
#include <itpp/base/mat.h>
#include <itpp/base/converters.h>
#include <itpp/itexports.h>
namespace itpp
{
ITPP_EXPORT ivec find(const bvec &invector);
ITPP_EXPORT vec ones(int size);
ITPP_EXPORT bvec ones_b(int size);
ITPP_EXPORT ivec ones_i(int size);
ITPP_EXPORT cvec ones_c(int size);
ITPP_EXPORT mat ones(int rows, int cols);
ITPP_EXPORT bmat ones_b(int rows, int cols);
ITPP_EXPORT imat ones_i(int rows, int cols);
ITPP_EXPORT cmat ones_c(int rows, int cols);
ITPP_EXPORT vec zeros(int size);
ITPP_EXPORT bvec zeros_b(int size);
ITPP_EXPORT ivec zeros_i(int size);
ITPP_EXPORT cvec zeros_c(int size);
ITPP_EXPORT mat zeros(int rows, int cols);
ITPP_EXPORT bmat zeros_b(int rows, int cols);
ITPP_EXPORT imat zeros_i(int rows, int cols);
ITPP_EXPORT cmat zeros_c(int rows, int cols);
ITPP_EXPORT mat eye(int size);
ITPP_EXPORT bmat eye_b(int size);
ITPP_EXPORT imat eye_i(int size);
ITPP_EXPORT cmat eye_c(int size);
template <class T>
void eye(int size, Mat<T> &m)
{
m.set_size(size, size, false);
m = T(0);
for (int i = size - 1; i >= 0; i--)
m(i, i) = T(1);
}
ITPP_EXPORT vec impulse(int size);
ITPP_EXPORT vec linspace(double from, double to, int length = 100);
template<class T>
Vec<T> linspace_fixed_step(T from, T to, T step = 1)
{
int points = 0;
if (0 != step) {
points = itpp::floor_i(double(to-from)/step)+1;
}
if (0 >= points) {
return Vec<T>(0);
}
Vec<T> output(points);
output(0) = from;
for (int n = 1; n < points; ++n) {
output(n) = output(n-1)+step;
}
return output;
}
ITPP_EXPORT vec zigzag_space(double t0, double t1, int K = 5);
ITPP_EXPORT imat hadamard(int size);
ITPP_EXPORT imat jacobsthal(int p);
ITPP_EXPORT imat conference(int n);
template <typename Num_T>
const Mat<Num_T> toeplitz(const Vec<Num_T> &c, const Vec<Num_T> &r)
{
int n_rows = c.size();
int n_cols = r.size();
Mat<Num_T> output(n_rows, n_cols);
for (int i = 0; i < n_rows; ++i) {
int j_limit = std::min(n_cols, n_rows - i);
for (int j = 0; j < j_limit; ++j) {
output(i + j, j) = c(i);
}
}
for (int j = 1; j < n_cols; ++j) {
int i_limit = std::min(n_rows, n_cols - j);
for (int i = 0; i < i_limit; ++i) {
output(i, i + j) = r(j);
}
}
return output;
}
template <typename Num_T>
const Mat<Num_T> toeplitz(const Vec<Num_T> &c)
{
int s = c.size();
Mat<Num_T> output(s, s);
for (int i = 0; i < s; ++i) {
for (int j = 0; j < s - i; ++j) {
output(i + j, j) = c(i);
}
}
for (int j = 1; j < s; ++j) {
for (int i = 0; i < s - j; ++i) {
output(i, i + j) = c(j);
}
}
return output;
}
ITPP_EXPORT const cmat toeplitz(const cvec &c);
ITPP_EXPORT mat rotation_matrix(int dim, int plane1, int plane2, double angle);
ITPP_EXPORT void house(const vec &x, vec &v, double &beta);
ITPP_EXPORT void givens(double a, double b, double &c, double &s);
ITPP_EXPORT void givens(double a, double b, mat &m);
ITPP_EXPORT mat givens(double a, double b);
ITPP_EXPORT void givens_t(double a, double b, mat &m);
ITPP_EXPORT mat givens_t(double a, double b);
template <class T>
Vec<T> vec_1(T v0)
{
Vec<T> v(1);
v(0) = v0;
return v;
}
template <class T>
Vec<T> vec_2(T v0, T v1)
{
Vec<T> v(2);
v(0) = v0;
v(1) = v1;
return v;
}
template <class T>
Vec<T> vec_3(T v0, T v1, T v2)
{
Vec<T> v(3);
v(0) = v0;
v(1) = v1;
v(2) = v2;
return v;
}
template <class T>
Mat<T> mat_1x1(T m00)
{
Mat<T> m(1, 1);
m(0, 0) = m00;
return m;
}
template <class T>
Mat<T> mat_1x2(T m00, T m01)
{
Mat<T> m(1, 2);
m(0, 0) = m00;
m(0, 1) = m01;
return m;
}
template <class T>
Mat<T> mat_2x1(T m00,
T m10)
{
Mat<T> m(2, 1);
m(0, 0) = m00;
m(1, 0) = m10;
return m;
}
template <class T>
Mat<T> mat_2x2(T m00, T m01,
T m10, T m11)
{
Mat<T> m(2, 2);
m(0, 0) = m00;
m(0, 1) = m01;
m(1, 0) = m10;
m(1, 1) = m11;
return m;
}
template <class T>
Mat<T> mat_1x3(T m00, T m01, T m02)
{
Mat<T> m(1, 3);
m(0, 0) = m00;
m(0, 1) = m01;
m(0, 2) = m02;
return m;
}
template <class T>
Mat<T> mat_3x1(T m00,
T m10,
T m20)
{
Mat<T> m(3, 1);
m(0, 0) = m00;
m(1, 0) = m10;
m(2, 0) = m20;
return m;
}
template <class T>
Mat<T> mat_2x3(T m00, T m01, T m02,
T m10, T m11, T m12)
{
Mat<T> m(2, 3);
m(0, 0) = m00;
m(0, 1) = m01;
m(0, 2) = m02;
m(1, 0) = m10;
m(1, 1) = m11;
m(1, 2) = m12;
return m;
}
template <class T>
Mat<T> mat_3x2(T m00, T m01,
T m10, T m11,
T m20, T m21)
{
Mat<T> m(3, 2);
m(0, 0) = m00;
m(0, 1) = m01;
m(1, 0) = m10;
m(1, 1) = m11;
m(2, 0) = m20;
m(2, 1) = m21;
return m;
}
template <class T>
Mat<T> mat_3x3(T m00, T m01, T m02,
T m10, T m11, T m12,
T m20, T m21, T m22)
{
Mat<T> m(3, 3);
m(0, 0) = m00;
m(0, 1) = m01;
m(0, 2) = m02;
m(1, 0) = m10;
m(1, 1) = m11;
m(1, 2) = m12;
m(2, 0) = m20;
m(2, 1) = m21;
m(2, 2) = m22;
return m;
}
} //namespace itpp
#endif // #ifndef SPECMAT_H
itpp::Array
General array class.
Definition array.h:105
itpp::Array::size
int size() const
Returns the number of data elements in the array object.
Definition array.h:155
itpp::Array::set_size
void set_size(int n, bool copy=false)
Resizing an Array<T>.
Definition array.h:257
itpp::Mat::mat_3x3
Mat< T > mat_3x3(T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22)
Matrix of size 3 by 3.
Definition specmat.h:483
itpp::Mat::mat_1x2
Mat< T > mat_1x2(T m00, T m01)
Matrix of size 1 by 2.
Definition specmat.h:373
itpp::Mat::mat_2x1
Mat< T > mat_2x1(T m00, T m10)
Matrix of size 2 by 1.
Definition specmat.h:386
itpp::Mat::mat_3x1
Mat< T > mat_3x1(T m00, T m10, T m20)
Matrix of size 3 by 1.
Definition specmat.h:430
itpp::Mat::mat_2x2
Mat< T > mat_2x2(T m00, T m01, T m10, T m11)
Matrix of size 2 by 2.
Definition specmat.h:400
itpp::Mat::mat_1x3
Mat< T > mat_1x3(T m00, T m01, T m02)
Matrix of size 1 by 3.
Definition specmat.h:416
itpp::Mat::mat_2x3
Mat< T > mat_2x3(T m00, T m01, T m02, T m10, T m11, T m12)
Matrix of size 2 by 3.
Definition specmat.h:446
itpp::Mat::mat_3x2
Mat< T > mat_3x2(T m00, T m01, T m10, T m11, T m20, T m21)
Matrix of size 3 by 2.
Definition specmat.h:464
itpp::Mat::mat_1x1
Mat< T > mat_1x1(T m00)
Matrix of size 1 by 1.
Definition specmat.h:361
itpp::Vec::vec_3
Vec< T > vec_3(T v0, T v1, T v2)
Vector of length 3.
Definition specmat.h:347
itpp::Vec::vec_1
Vec< T > vec_1(T v0)
Vector of length 1.
Definition specmat.h:322
itpp::Vec::vec_2
Vec< T > vec_2(T v0, T v1)
Vector of length 2.
Definition specmat.h:334
converters.h
Definitions of converters between different vector and matrix types.
itpp::to
T to(double x)
Convert double to T.
Definition fix_functions.h:365
itpp::size
int size(const Vec< T > &v)
Length of vector.
Definition matfunc.h:55
itpp::length
int length(const Vec< T > &v)
Length of vector.
Definition matfunc.h:51
itpp::angle
vec angle(const cvec &x)
Angle.
Definition elem_math.h:218
itpp::givens_t
void givens_t(double a, double b, mat &m)
Calculate the transposed Givens rotation matrix.
Definition specmat.cpp:336
itpp::house
void house(const vec &x, vec &v, double &beta)
Calcualte the Householder vector.
Definition specmat.cpp:251
itpp::rotation_matrix
mat rotation_matrix(int dim, int plane1, int plane2, double angle)
Create a rotation matrix that rotates the given plane angle radians. Note that the order of the plane...
Definition specmat.cpp:229
itpp::find
ivec find(const bvec &invector)
Return a integer vector with indicies where bvec == 1.
Definition specmat.cpp:40
itpp::givens
void givens(double a, double b, double &c, double &s)
Calculate the Givens rotation values.
Definition specmat.cpp:277
itpp::linspace
vec linspace(double from, double to, int points)
linspace (works in the same way as the MATLAB version)
Definition specmat.cpp:106
itpp::zeros
ITPP_EXPORT vec zeros(int size)
A Double vector of zeros.
itpp::toeplitz
const cmat toeplitz(const cvec &c)
Generate symmetric Toeplitz matrix from vector c (complex valued)
Definition specmat.cpp:210
itpp::zeros_c
ITPP_EXPORT cvec zeros_c(int size)
A Double Complex vector of zeros.
itpp::eye_c
ITPP_EXPORT cmat eye_c(int size)
A Double Complex (size,size) unit matrix.
itpp::hadamard
imat hadamard(int size)
Hadamard matrix.
Definition specmat.cpp:149
itpp::ones_i
ITPP_EXPORT ivec ones_i(int size)
A Int vector of ones.
itpp::eye_i
ITPP_EXPORT imat eye_i(int size)
A Int (size,size) unit matrix.
itpp::impulse
vec impulse(int size)
Impulse vector.
Definition specmat.cpp:98
itpp::eye_b
ITPP_EXPORT bmat eye_b(int size)
A Binary (size,size) unit matrix.
itpp::conference
imat conference(int n)
Conference matrix.
Definition specmat.cpp:196
itpp::ones_c
ITPP_EXPORT cvec ones_c(int size)
A float Complex vector of ones.
itpp::ones_b
ITPP_EXPORT bvec ones_b(int size)
A Binary vector of ones.
itpp::zeros_b
ITPP_EXPORT bvec zeros_b(int size)
A Binary vector of zeros.
itpp::ones
ITPP_EXPORT vec ones(int size)
A float vector of ones.
itpp::jacobsthal
imat jacobsthal(int p)
Jacobsthal matrix.
Definition specmat.cpp:172
itpp::zigzag_space
vec zigzag_space(double t0, double t1, int K)
Zig-zag space function (variation on linspace)
Definition specmat.cpp:125
itpp::zeros_i
ITPP_EXPORT ivec zeros_i(int size)
A Int vector of zeros.
mat.h
Matrix Class Definitions.
bmat
Mat< bin > bmat
bin matrix
Definition mat.h:508
itpp
itpp namespace
Definition itmex.h:37
itpp::linspace_fixed_step
template vec linspace_fixed_step(double, double, double)
Template instantiation of linspace_fixed_step.
itpp::eye
template void eye(int, mat &)
Template instantiation of eye.
itpp::floor_i
int floor_i(double x)
The nearest smaller integer.
Definition converters.h:350
vec.h
Templated Vector Class Definitions.

Generated on Mon Jun 10 2024 11:49:19 for IT++ by Doxygen 1.9.8