12#ifndef __CODAC2_VECTOR_H__
13#define __CODAC2_VECTOR_H__
23 template<
int N=Dynamic>
24 class Vector_ :
public Matrix_<N,1>
34 assert(N == Dynamic || N == (
int)n);
37 Vector_(
size_t n,
double x)
40 assert(N == Dynamic || N == (
int)n);
43 Vector_(std::initializer_list<double> l) : Matrix_<N,1>(l.size(),1)
45 assert(N == (
int)l.size() || N == -1);
52 Vector_(
const Matrix_<M,1>& x)
55 static_assert(M == Dynamic || M == N);
58 explicit Vector_(
size_t n,
const double values[])
59 : Matrix_<N,1>(n,1,values)
62 explicit Vector_(
const double values[])
63 : Matrix_<N,1>(N,1,values)
66 template<
typename T,
size_t M>
67 explicit Vector_(
const std::array<T,M>& array)
70 static_assert(N == Dynamic || N == (int)M);
71 for(
size_t i = 0 ; i < M ; i++)
72 *(this->data()+i) = array[i];
75 template<
typename OtherDerived>
76 Vector_(
const Eigen::MatrixBase<OtherDerived>& other)
81 template<
typename OtherDerived>
82 Vector_& operator=(
const Eigen::MatrixBase<OtherDerived>& other)
84 this->Eigen::Matrix<double,N,1>::operator=(other);
88 Matrix_<N,N> as_diag()
const
90 return Matrix_<N,N>(Eigen::Matrix<double,N,N>(this->asDiagonal()));
93 Matrix_<1,N> transpose()
const
95 return Matrix_<1,N>(Eigen::Matrix<double,N,1>::transpose());
99 template<
size_t N1,
size_t N2>
100 Vector_<N2-N1+1> subvector()
const
102 assert(N1 >= 0 && N1 < N && N2 >= 0 && N2 < N && N1 <= N2);
103 return this->
template block<N2-N1+1,1>(N1,0);
108 std::ostream& operator<<(std::ostream& os,
const Vector_<N>& x)
111 for(
size_t i = 0 ; i < x.size() ; i++)
112 os << x[i] << (i<x.size()-1 ?
" ; " :
"");
118 Matrix_<N,N> diag(
const Vector_<N> v)
124 codac::Vector to_codac1(
const Vector_<N>& x)
126 ibex::Vector x_(x.size());
127 for(
size_t i = 0 ; i < x.size() ; i++)
133 Vector_<N> to_codac2(
const codac::Vector& x)
135 assert(x.size() == N);
137 for(
size_t i = 0 ; i < N ; i++)
142 class Vector :
public Vector_<>
146 explicit Vector(
int n)
150 Vector(
const Vector& x)
154 explicit Vector(std::initializer_list<double> l)
159 Vector(
const Vector_<N>& v)
164 Vector(
const Matrix_<N,1>& v)