20 template<
class F,
class G>
86 std::memcpy(v_, data, this->
dim_ *
sizeof(v_[0]));
90 std::memcpy(v_, data, this->
dim_ *
sizeof(v_[0]));
190 operator F*()
const {
return v_; }
192 F* data()
const {
return v_; }
236 bool append =
false)
const;
238 virtual std::ostream&
info(std::ostream&
os)
const;
248 static uint storeMatlabCounter_;
254 Function<F>(f.dim()), data_(
this->dim_), v_((F*)data_) {
272 fillEntries_(spc,
lf);
288 Function<F>(indices.dim()), data_(
this->dim_), v_((F*)data_)
292 i != indices.index_end(); )
300 for(
uint i = 0; i < this->dim_; ++i) v_[i] =
fnc(i);
310 const H* s = (H*)
fnc;
311 for (
uint i = std::min(this->dim_-offset,
fnc.dim()); i; --i) *d++ +=
sc * *s++;
317 F *
p1 = (F*)data_, *
p2 = (F*)data_ + (data_.size()-1);
318 for(
uint i = std::floor(
double(data_.size())/2.0); i--; )
319 std::swap(*
p1++, *
p2--);
uint dim_
Dimension of the function (or of the space the function is defined)
uint dim() const
Returns the dimension of the function.
virtual F & operator()(uint i)
Index operator.
Vector< F > & operator=(const Vector< F > &fnc)
Assignement operator.
Vector(const Vector< H > &fnc, const Set< IndexRange > &indices)
Vector(const Vector< F > &f)
Copy constructor.
virtual F operator()(uint i) const
Index operator.
virtual void resize(uint n)
Sets a new size, previous data might be lost
virtual Function< F > & operator+=(F c)
Addition operator.
virtual Function< F > & operator-=(F c)
Subtraction operator.
Vector< F > & operator=(F c)
Assignement operator.
Vector(const Vector< H > &fncX, F fnc(const H &))
Vector< F > & add(const Vector< H > &fnc, F sc, uint offset=0)
Adds a vector of possible different length and type with an offset.
Vector(const Vector< typename Realtype< F >::type > &V_R, const Vector< typename Realtype< F >::type > &V_I)
void storeMatlab(const char *filename, const char *name=0, bool append=false) const
Stores the vector in a Matlab sparse matrix.
uint n() const
Elements in the vector.
Vector(const Space< G > &spc)
virtual Function< F > & operator*=(F sc)
Scaling operator.
const Vector< F > & write(const std::string &fname) const
Vector< F > & add(const Vector< H > &fnc)
Adds a vector of possible different length and type.
Vector< F > & apply(F fnc(const F &))
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Vector(const Space< G > &spc, const std::string &fname)
Array< F > data_
Vector data.
Vector< F > & assemble(const Space< G > &spc, const LinearForm< F, G > &lf)
Assembles the vector w.r.t. linear form lf and space spc.
virtual Function< F > & operator-=(const Function< F > &fnc)
Subtraction operator.
virtual Vector< F > & operator=(const Function< F > &fnc)
Assignment operator.
Vector(const Space< G > &spc, F *data)
virtual Function< F > & operator+=(const Function< F > &fnc)
Addition operator.
virtual Function< F > & add(const Function< F > &fnc, F sc)
Adds a times fnc to this function.
Real max() const
Maximum of the absolute values in the vector, ie. norm.
Real l2_2() const
l2 norm squared
Vector(const Vector< H > &f)
Copy constructor.
Vector(const Space< G > &spc, const LinearForm< F, G > &lf)
F operator*(const Vector< F > &fnc) const
#define conceptsAssert3(cond, exc, msg)
void memorycpy(F *dest, const G *src, size_t n)
Copies n entries from src to dest (faster than std::memcpy)
Set< F > makeSet(uint n, const F &first,...)