40 template<
typename DataType>
48 template<
typename DataType>
56 template<
typename DataType>
65 template<
typename DataType>
73 std::vector<DataType> values = FromString<DataType>(vectorValues);
80 catch(std::runtime_error& e)
86 template<
typename DataType>
88 typename boost::call_traits<DataType>::const_reference y,
89 typename boost::call_traits<DataType>::const_reference z) :
99 template<
typename DataType>
101 m_size(rhs.GetDimension()),
103 m_wrapperType(rhs.m_wrapperType)
112 template<
typename DataType>
120 template<
typename DataType>
133 template<
typename DataType>
141 ASSERTL0(size <= ptr.
size(),
"Attempting to populate a vector of size " +
142 std::to_string(size) +
" but the incoming array only has " +
143 std::to_string(ptr.
size()) +
" elements.");
150 template<
typename DataType>
163 template<
typename DataType>
171 ASSERTL0(size <= ptr.
size(),
"Attempting to populate a vector of size " +
172 std::to_string(size) +
" but the incoming array only has " +
173 std::to_string(ptr.
size()) +
" elements.");
180 template<
typename DataType>
183 template<
typename DataType>
186 if( m_wrapperType ==
eCopy )
196 else if( m_wrapperType ==
eWrapper )
200 ASSERTL0(GetDimension() == rhs.
GetDimension(),
"Wrapped NekVectors must have the same dimension in operator=");
208 template<
typename DataType>
214 template<
typename DataType>
220 template<
typename DataType>
223 return this->GetData().get();
226 template<
typename DataType>
229 template<
typename DataType>
235 template<
typename DataType>
238 template<
typename DataType>
241 template<
typename DataType>
244 template<
typename DataType>
247 template<
typename DataType>
250 template<
typename DataType>
254 "Invalid access to m_data via parenthesis operator");
255 return this->GetData()[i];
258 template<
typename DataType>
261 return this->GetData()[i];
264 template<
typename DataType>
267 ASSERTL1(this->GetDimension() >= 1,
"Invalid use of NekVector::x");
271 template<
typename DataType>
274 ASSERTL1(this->GetDimension() >= 2,
"Invalid use of NekVector::y");
278 template<
typename DataType>
281 ASSERTL1(this->GetDimension() >= 3,
"Invalid use of NekVector::z");
285 template<
typename DataType>
288 ASSERTL1(this->GetDimension() >= 1,
"Invalid use of NekVector::SetX");
289 this->GetData()[0] = val;
292 template<
typename DataType>
295 ASSERTL1(this->GetDimension() >= 2,
"Invalid use of NekVector::SetX");
296 this->GetData()[1] = val;
299 template<
typename DataType>
302 ASSERTL1(this->GetDimension() >= 3,
"Invalid use of NekVector::SetX");
303 this->GetData()[2] = val;
306 template<
typename DataType>
313 template<
typename DataType>
320 template<
typename DataType>
327 template<
typename DataType>
334 template<
typename DataType>
337 template<
typename DataType>
341 "Invalid access to m_data via parenthesis operator");
345 template<
typename DataType>
351 template<
typename DataType>
354 ASSERTL1( GetDimension() >= 1,
"Invalid use of NekVector::x");
358 template<
typename DataType>
361 ASSERTL1( GetDimension() >= 2,
"Invalid use of NekVector::y");
365 template<
typename DataType>
368 ASSERTL1( GetDimension() >= 3,
"Invalid use of NekVector::z");
372 template<
typename DataType>
375 template<
typename DataType>
378 template<
typename DataType>
381 template<
typename DataType>
387 template<
typename DataType>
391 template<
typename DataType>
394 template<
typename DataType>
397 template<
typename DataType>
400 template<
typename DataType>
403 template<
typename DataType>
406 template<
typename DataType>
409 template<
typename DataType>
412 template<
typename DataType>
415 template<
typename DataType>
418 if(m_data.size() < newSize )
428 template<
typename DataType>
434 const DataType* lhs_buf = lhs.
GetRawPtr();
435 const DataType* rhs_buf = rhs.
GetRawPtr();
437 for(
int i = 0; i < ldim; ++i)
439 r_buf[i] = lhs_buf[i] + rhs_buf[i];
443 template<
typename DataType>
449 const DataType* lhs_buf = lhs.
GetRawPtr();
450 const DataType* rhs_buf = rhs.
GetRawPtr();
452 for(
int i = 0; i < ldim; ++i)
454 r_buf[i] = -lhs_buf[i] + rhs_buf[i];
472 template<
typename DataType>
477 const DataType* rhs_buf = rhs.
GetRawPtr();
479 for(
int i = 0; i < rdim; ++i)
481 r_buf[i] += rhs_buf[i];
485 template<
typename DataType>
490 const DataType* rhs_buf = rhs.
GetRawPtr();
492 for(
int i = 0; i < rdim; ++i)
494 r_buf[i] = -r_buf[i] + rhs_buf[i];
512 template<
typename LhsDataType,
513 typename RhsDataType>
518 Add(result, lhs, rhs);
530 template<
typename ResultDataType,
typename InputDataType>
535 ResultDataType* r_buf = result.
GetRawPtr();
536 typename std::add_const<InputDataType>::type* lhs_buf = lhs.
GetRawPtr();
537 typename std::add_const<InputDataType>::type* rhs_buf = rhs.
GetRawPtr();
539 for(
int i = 0; i < ldim; ++i)
541 r_buf[i] = lhs_buf[i] - rhs_buf[i];
545 template<
typename ResultDataType,
typename InputDataType>
550 ResultDataType* r_buf = result.
GetRawPtr();
551 typename std::add_const<InputDataType>::type* lhs_buf = lhs.
GetRawPtr();
552 typename std::add_const<InputDataType>::type* rhs_buf = rhs.
GetRawPtr();
554 for(
int i = 0; i < ldim; ++i)
556 r_buf[i] = -lhs_buf[i] - rhs_buf[i];
580 template<
typename ResultDataType,
typename InputDataType>
584 ResultDataType* r_buf = result.
GetRawPtr();
585 typename std::add_const<InputDataType>::type* rhs_buf = rhs.
GetRawPtr();
587 for(
int i = 0; i < rdim; ++i)
589 r_buf[i] -= rhs_buf[i];
593 template<
typename ResultDataType,
typename InputDataType>
597 ResultDataType* r_buf = result.
GetRawPtr();
598 typename std::add_const<InputDataType>::type* rhs_buf = rhs.
GetRawPtr();
600 for(
int i = 0; i < rdim; ++i)
602 r_buf[i] = -r_buf[i] - rhs_buf[i];
622 template<
typename DataType>
642 template<
typename ResultDataType,
typename InputDataType>
647 ResultDataType* r_buf = result.
GetRawPtr();
648 typename std::add_const<InputDataType>::type* lhs_buf = lhs.
GetRawPtr();
651 for(
int i = 0; i < ldim; ++i)
653 r_buf[i] = lhs_buf[i] / rhs;
657 template<
typename ResultDataType,
typename InputDataType>
662 ResultDataType* r_buf = result.
GetRawPtr();
663 typename std::add_const<InputDataType>::type* lhs_buf = lhs.
GetRawPtr();
666 for(
int i = 0; i < ldim; ++i)
668 r_buf[i] = lhs_buf[i] / rhs;
682 template<
typename ResultDataType>
686 ResultDataType* r_buf = result.
GetRawPtr();
689 for(
int i = 0; i < resdim; ++i)
695 template<
typename ResultDataType>
699 ResultDataType* r_buf = result.
GetRawPtr();
702 for(
int i = 0; i < resdim; ++i)
716 template<
typename DataType>
726 template<
typename DataType>
746 template<
typename ResultDataType,
typename InputDataType>
751 ResultDataType* result_buf = result.
GetRawPtr();
752 const InputDataType* rhs_buf = rhs.
GetRawPtr();
753 const InputDataType* lhs_buf = lhs.
GetRawPtr();
755 for(
int i = 0; i < resdim; ++i)
757 result_buf[i] = lhs_buf[i] * rhs_buf[i];
767 template<
typename ResultDataType,
typename InputDataType>
771 ResultDataType* result_buf = result.
GetRawPtr();
772 const InputDataType* rhs_buf = rhs.
GetRawPtr();
774 for(
int i = 0; i < resdim; ++i)
776 result_buf[i] *= rhs_buf[i];
786 template<
typename DataType,
typename InputDataType>
805 template<
typename ResultDataType,
typename InputDataType>
810 ResultDataType* r_buf = result.
GetRawPtr();
811 const InputDataType* lhs_buf = lhs.
GetRawPtr();
814 for(
int i = 0; i < ldim; ++i)
816 r_buf[i] = lhs_buf[i] * rhs;
820 template<
typename ResultDataType,
typename InputDataType>
825 ResultDataType* r_buf = result.
GetRawPtr();
826 const InputDataType* lhs_buf = lhs.
GetRawPtr();
829 for(
int i = 0; i < ldim; ++i)
831 r_buf[i] = lhs_buf[i] * rhs;
845 template<
typename ResultDataType>
849 ResultDataType* r_buf = result.
GetRawPtr();
851 for(
unsigned int i = 0; i < rdim; ++i)
857 template<
typename ResultDataType>
861 ResultDataType* r_buf = result.
GetRawPtr();
863 for(
unsigned int i = 0; i < rdim; ++i)
876 template<
typename DataType>
886 template<
typename DataType>
906 template<
typename ResultDataType,
typename InputDataType>
914 template<
typename ResultDataType,
typename InputDataType>
919 ResultDataType* r_buf = result.
GetRawPtr();
920 const InputDataType* rhs_buf = rhs.
GetRawPtr();
924 for(
int i = 0; i < rdim; ++i)
926 r_buf[i] = inverse * rhs_buf[i];
930 template<
typename ResultDataType,
typename InputDataType>
938 template<
typename ResultDataType,
typename InputDataType>
943 ResultDataType* r_buf = result.
GetRawPtr();
944 const InputDataType* rhs_buf = rhs.
GetRawPtr();
948 for(
int i = 0; i < rdim; ++i)
950 r_buf[i] = inverse * rhs_buf[i];
974 template<
typename DataType>
989 template<
typename DataType>
1002 template<
typename DataType>
1007 for(
unsigned int i = 0; i < 3; ++i)
1009 result[i] = dest[i]-source[i];
1023 template<
typename DataType>
1028 for(
unsigned int i = 0; i < 3; ++i)
1030 result[i] = lhs[i]*t;
1044 template<
typename DataType>
1064 template<
typename DataType>
1068 return !(lhs == rhs);
1079 template<
typename DataType>
1082 std::vector<DataType> result;
1086 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
1087 boost::char_separator<char> sep(
"(<,>) ");
1088 tokenizer tokens(str, sep);
1089 for( tokenizer::iterator strIter = tokens.begin(); strIter != tokens.end(); ++strIter)
1091 result.push_back(boost::lexical_cast<DataType>(*strIter));
1094 catch(boost::bad_lexical_cast&)
1102 std::vector<NekDouble>
FromString(
const std::string& str);
1105 std::vector<NekSingle>
FromString(
const std::string& str);
1107 template<
typename DataType>
1113 for(
typename VectorType::const_iterator iter = v.
begin(); iter != v.
end(); ++iter)
1115 result += fabs(*iter);
1127 template<
typename DataType>
1133 for(
typename VectorType::const_iterator iter = v.
begin(); iter != v.
end(); ++iter)
1135 DataType v = fabs(*iter);
1138 return sqrt(result);
1147 template<
typename DataType>
1150 DataType result = fabs(v[0]);
1152 for(
unsigned int i = 0; i < vdim; ++i)
1154 result = std::max(DataType(fabs(v[i])), result);
1165 template<
typename DataType>
1170 for(
unsigned int i = 0; i < tdim; ++i)
1183 template<
typename DataType>
1188 for(
unsigned int i = 0; i < vdim; ++i)
1200 template<
typename DataType>
1203 DataType result = DataType(0);
1206 for(
unsigned int i = 0; i < vdim; ++i)
1208 result += v[i]*v[i];
1210 return sqrt(result);
1219 template<
typename DataType>
1225 DataType result = DataType(0);
1227 for(
unsigned int i = 0; i < ldim; ++i)
1229 result += lhs[i]*rhs[i];
1243 template<
typename DataType>
1247 if( m > DataType(0) )
1265 template<
typename DataType>
1271 DataType first = lhs.
y()*rhs.
z() - lhs.
z()*rhs.
y();
1272 DataType second = lhs.
z()*rhs.
x() - lhs.
x()*rhs.
z();
1273 DataType third = lhs.
x()*rhs.
y() - lhs.
y()*rhs.
x();
1285 template<
typename DataType>
1289 std::string result =
"(";
1290 for(
unsigned int i = 0; i < d; ++i)
1292 result += boost::lexical_cast<std::string>(v[i]);
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define LIB_UTILITIES_EXPORT
Array< OneD, const DataType >::const_iterator begin() const
1D Array of constant elements with garbage collection and bounds checking.
const_iterator begin() const
size_type size() const
Returns the array's size.
boost::call_traits< DataType >::reference x()
void SetZ(typename boost::call_traits< DataType >::const_reference val)
void SetWrapperType(PointerWrapper p)
boost::call_traits< DataType >::reference operator[](unsigned int i)
Array< OneD, DataType > & GetData()
NekVector< DataType > Cross(const NekVector< DataType > &rhs) const
Array< OneD, DataType > & GetPtr()
unsigned int GetDimension() const
Returns the number of dimensions for the point.
NekVector< DataType > & operator+=(const NekVector< DataType > &rhs)
NekVector< DataType > & operator=(const NekVector< DataType > &rhs)
PointerWrapper GetWrapperType() const
void SetY(typename boost::call_traits< DataType >::const_reference val)
Array< OneD, DataType > m_data
void Resize(unsigned int newSize)
PointerWrapper m_wrapperType
DataType Dot(const NekVector< DataType > &rhs) const
unsigned int GetRows() const
std::string AsString() const
void SetSize(unsigned int s)
NekVector< DataType > & operator/=(typename boost::call_traits< DataType >::const_reference rhs)
boost::call_traits< DataType >::reference y()
NekVector< DataType > & operator*=(typename boost::call_traits< DataType >::const_reference rhs)
const DataType * const_iterator
DataType InfinityNorm() const
boost::call_traits< DataType >::reference operator()(unsigned int i)
Returns i^{th} element.
DataType Magnitude() const
NekVector< DataType > & operator-=(const NekVector< DataType > &rhs)
NekVector()
Creates an empty vector.
void SetData(const Array< OneD, DataType > &newData)
boost::call_traits< DataType >::reference z()
NekVector< DataType > operator-() const
void SetX(typename boost::call_traits< DataType >::const_reference val)
The above copyright notice and this permission notice shall be included.
void Normalize(NekVector< DataType > &v)
std::string AsString(const NekVector< DataType > &v)
bool operator==(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)
void InvertInPlace(NekDouble &v)
SNekMat SNekMat void SubtractEqual(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
void MultiplyInvertedLhs(NekVector< ResultDataType > &result, const NekDouble &lhs, const NekVector< InputDataType > &rhs)
void AddEqualNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
SNekMat void AddEqual(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
DataType InfinityNorm(const NekVector< DataType > &v)
void Divide(NekVector< ResultDataType > &result, const NekVector< InputDataType > &lhs, const NekDouble &rhs)
NekVector< DataType > Negate(const NekVector< DataType > &v)
void Subtract(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
std::vector< DataType > FromString(const std::string &str)
void Multiply(NekMatrix< ResultDataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const ResultDataType &rhs)
void DivideEqual(NekVector< ResultDataType > &result, const NekDouble &rhs)
NekVector< DataType > createVectorFromPoints(const NekPoint< DataType > &source, const NekPoint< DataType > &dest)
void AddNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
void SubtractEqualNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
void NegateInPlace(NekVector< DataType > &v)
DataType Magnitude(const NekVector< DataType > &v)
const NekSingle void MultiplyEqual(NekMatrix< LhsDataType, StandardMatrixTag > &lhs, typename boost::call_traits< LhsDataType >::const_reference rhs)
NekVector< DataType > Cross(const NekVector< DataType > &lhs, const NekVector< DataType > &rhs)
void SubtractNegatedLhs(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
std::ostream & operator<<(std::ostream &os, const NekMatrix< DataType, FormType > &rhs)
DataType L2Norm(const NekVector< DataType > &v)
DataType L1Norm(const NekVector< DataType > &v)
NekPoint< DataType > findPointAlongVector(const NekVector< DataType > &lhs, const DataType &t)
bool operator!=(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)
PointerWrapper
Specifies if the pointer passed to a NekMatrix or NekVector is copied into an internal representation...
SNekMat SNekMat void Add(NekMatrix< DataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
DataType Dot(const NekVector< DataType > &lhs, const NekVector< DataType > &rhs)
void CopyArray(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest)
scalarT< T > sqrt(scalarT< T > in)