Skip to content
Snippets Groups Projects
Commit ac7139f9 authored by Christian Engwer's avatar Christian Engwer
Browse files

* update FieldVector such that the vector test passes also for complex

  valued data

[[Imported from SVN: r6177]]
parent 021ae546
No related branches found
No related tags found
No related merge requests found
......@@ -142,7 +142,6 @@ namespace Dune {
};
typedef typename Base::size_type size_type;
typedef typename Base::value_type value_type;
//===== construction
......@@ -150,7 +149,7 @@ namespace Dune {
FieldVector () {}
/** \brief Constructor with a given scalar */
FieldVector (const K& k) { (*this)[0] = k; }
FieldVector (const K& k) : _data(k) {}
using Base::operator=;
......@@ -170,69 +169,45 @@ namespace Dune {
//===== conversion operator
/** \brief Conversion operator */
operator K () { return (*this)[0]; }
operator K () { return _data; }
/** \brief Const conversion operator */
operator K () const { return (*this)[0]; }
operator K () const { return _data; }
};
//! Binary vector addition
template<class K>
inline FieldVector<K,1> operator+ (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
{
return a[0]+b[0];
}
//! Binary vector subtraction
template<class K>
inline FieldVector<K,1> operator- (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
{
return a[0]-b[0];
}
/* ----- FV / FV ----- */
/* not necessary as these operations are already covered via the cast operator */
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator> (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
{
return a[0]>b[0];
}
/* ----- FV / scalar ----- */
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator>= (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
{
return a[0]>=b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
//! Binary addition, when using FieldVector<K,1> like K
template<class K>
inline bool operator< (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
inline FieldVector<K,1> operator+ (const FieldVector<K,1>& a, const K b)
{
return a[0]<b[0];
return a[0]+b;
}
//! Binary compare, when using FieldVector<K,1> like K
//! Binary subtraction, when using FieldVector<K,1> like K
template<class K>
inline bool operator<= (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
inline FieldVector<K,1> operator- (const FieldVector<K,1>& a, const K b)
{
return a[0]<=b[0];
return a[0]-b;
}
//! Binary addition, when using FieldVector<K,1> like K
//! Binary multiplication, when using FieldVector<K,1> like K
template<class K>
inline FieldVector<K,1> operator+ (const FieldVector<K,1>& a, const K b)
inline FieldVector<K,1> operator* (const FieldVector<K,1>& a, const K b)
{
return a[0]+b;
return a[0]*b;
}
//! Binary subtraction, when using FieldVector<K,1> like K
//! Binary division, when using FieldVector<K,1> like K
template<class K>
inline FieldVector<K,1> operator- (const FieldVector<K,1>& a, const K b)
inline FieldVector<K,1> operator/ (const FieldVector<K,1>& a, const K b)
{
return a[0]-b;
return a[0]/b;
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator> (const FieldVector<K,1>& a, const K b)
......@@ -261,6 +236,22 @@ namespace Dune {
return a[0]<=b;
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator== (const FieldVector<K,1>& a, const K b)
{
return a[0]==b;
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator!= (const FieldVector<K,1>& a, const K b)
{
return a[0]!=b;
}
/* ----- scalar / FV ------ */
//! Binary addition, when using FieldVector<K,1> like K
template<class K>
inline FieldVector<K,1> operator+ (const K a, const FieldVector<K,1>& b)
......@@ -275,6 +266,20 @@ namespace Dune {
return a-b[0];
}
//! Binary multiplication, when using FieldVector<K,1> like K
template<class K>
inline FieldVector<K,1> operator* (const K a, const FieldVector<K,1>& b)
{
return a*b[0];
}
//! Binary division, when using FieldVector<K,1> like K
template<class K>
inline FieldVector<K,1> operator/ (const K a, const FieldVector<K,1>& b)
{
return a/b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator> (const K a, const FieldVector<K,1>& b)
......@@ -302,6 +307,20 @@ namespace Dune {
{
return a<=b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator== (const K a, const FieldVector<K,1>& b)
{
return a==b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator!= (const K a, const FieldVector<K,1>& b)
{
return a!=b[0];
}
#endif
/** @} end documentation */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment