40template <
typename DataType>
45template <
typename DataType>
47 : m_size(size), m_data(size), m_wrapperType(
eCopy)
51template <
typename DataType>
53 unsigned int size,
typename boost::call_traits<DataType>::const_reference a)
54 : m_size(size), m_data(size), m_wrapperType(
eCopy)
59template <
typename DataType>
61 : m_size(0), m_data(), m_wrapperType(
eCopy)
65 std::vector<DataType> values = FromString<DataType>(vectorValues);
72 catch (std::runtime_error &e)
78template <
typename DataType>
80 typename boost::call_traits<DataType>::const_reference x,
81 typename boost::call_traits<DataType>::const_reference y,
82 typename boost::call_traits<DataType>::const_reference
z)
83 : m_size(3), m_data(m_size), m_wrapperType(
eCopy)
90template <
typename DataType>
92 : m_size(rhs.GetDimension()), m_data(rhs.m_data),
93 m_wrapperType(rhs.m_wrapperType)
95 if (m_wrapperType ==
eCopy)
102template <
typename DataType>
104 : m_size(size), m_data(size, ptr), m_wrapperType(
eCopy)
108template <
typename DataType>
111 : m_size(ptr.size()), m_data(ptr), m_wrapperType(h)
120template <
typename DataType>
123 : m_size(size), m_data(ptr), m_wrapperType(h)
128 "Attempting to populate a vector of size " +
129 std::to_string(size) +
130 " but the incoming array only has " +
131 std::to_string(ptr.
size()) +
" elements.");
138template <
typename DataType>
141 : m_size(ptr.size()), m_data(ptr), m_wrapperType(h)
150template <
typename DataType>
154 : m_size(size), m_data(ptr), m_wrapperType(h)
159 "Attempting to populate a vector of size " +
160 std::to_string(size) +
161 " but the incoming array only has " +
162 std::to_string(ptr.
size()) +
" elements.");
173template <
typename DataType>
177 if (m_wrapperType ==
eCopy)
193 "Wrapped NekVectors must have the same dimension in operator=");
200template <
typename DataType>
213 return this->GetData().get();
216template <
typename DataType>
219 return this->GetData();
222template <
typename DataType>
228template <
typename DataType>
234template <
typename DataType>
240template <
typename DataType>
243 return GetRawPtr() + this->GetDimension();
246template <
typename DataType>
252template <
typename DataType>
255 return GetRawPtr() + GetDimension();
258template <
typename DataType>
259typename boost::call_traits<DataType>::reference
NekVector<
260 DataType>::operator()(
unsigned int i)
263 "Invalid access to m_data via parenthesis operator");
264 return this->GetData()[i];
267template <
typename DataType>
268typename boost::call_traits<DataType>::reference
NekVector<
269 DataType>::operator[](
unsigned int i)
271 return this->GetData()[i];
274template <
typename DataType>
277 ASSERTL1(this->GetDimension() >= 1,
"Invalid use of NekVector::x");
281template <
typename DataType>
284 ASSERTL1(this->GetDimension() >= 2,
"Invalid use of NekVector::y");
288template <
typename DataType>
291 ASSERTL1(this->GetDimension() >= 3,
"Invalid use of NekVector::z");
295template <
typename DataType>
297 typename boost::call_traits<DataType>::const_reference val)
299 ASSERTL1(this->GetDimension() >= 1,
"Invalid use of NekVector::SetX");
300 this->GetData()[0] = val;
303template <
typename DataType>
305 typename boost::call_traits<DataType>::const_reference val)
307 ASSERTL1(this->GetDimension() >= 2,
"Invalid use of NekVector::SetX");
308 this->GetData()[1] = val;
311template <
typename DataType>
313 typename boost::call_traits<DataType>::const_reference val)
315 ASSERTL1(this->GetDimension() >= 3,
"Invalid use of NekVector::SetX");
316 this->GetData()[2] = val;
319template <
typename DataType>
327template <
typename DataType>
335template <
typename DataType>
337 typename boost::call_traits<DataType>::const_reference rhs)
343template <
typename DataType>
345 typename boost::call_traits<DataType>::const_reference rhs)
356template <
typename DataType>
357typename boost::call_traits<DataType>::const_reference
NekVector<
358 DataType>::operator()(
unsigned int i)
const
361 "Invalid access to m_data via parenthesis operator");
365template <
typename DataType>
366typename boost::call_traits<DataType>::const_reference
NekVector<
367 DataType>::operator[](
unsigned int i)
const
372template <
typename DataType>
376 ASSERTL1(GetDimension() >= 1,
"Invalid use of NekVector::x");
380template <
typename DataType>
384 ASSERTL1(GetDimension() >= 2,
"Invalid use of NekVector::y");
388template <
typename DataType>
392 ASSERTL1(GetDimension() >= 3,
"Invalid use of NekVector::z");
396template <
typename DataType>
407template <
typename DataType>
413template <
typename DataType>
441template <
typename DataType>
444 return m_wrapperType;
447template <
typename DataType>
458template <
typename DataType>
464template <
typename DataType>
470template <
typename DataType>
473 if (m_data.size() < newSize)
483template <
typename DataType>
488 const DataType *lhs_buf = lhs.
GetRawPtr();
489 const DataType *rhs_buf = rhs.
GetRawPtr();
491 for (
int i = 0; i < ldim; ++i)
493 r_buf[i] = lhs_buf[i] + rhs_buf[i];
497template <
typename DataType>
502 const DataType *lhs_buf = lhs.
GetRawPtr();
503 const DataType *rhs_buf = rhs.
GetRawPtr();
505 for (
int i = 0; i < ldim; ++i)
507 r_buf[i] = -lhs_buf[i] + rhs_buf[i];
525template <
typename DataType>
529 const DataType *rhs_buf = rhs.
GetRawPtr();
531 for (
int i = 0; i < rdim; ++i)
533 r_buf[i] += rhs_buf[i];
537template <
typename DataType>
542 const DataType *rhs_buf = rhs.
GetRawPtr();
544 for (
int i = 0; i < rdim; ++i)
546 r_buf[i] = -r_buf[i] + rhs_buf[i];
560template <
typename LhsDataType,
typename RhsDataType>
565 Add(result, lhs, rhs);
575template <
typename ResultDataType,
typename InputDataType>
580 ResultDataType *r_buf = result.
GetRawPtr();
581 typename std::add_const<InputDataType>::type *lhs_buf = lhs.
GetRawPtr();
582 typename std::add_const<InputDataType>::type *rhs_buf = rhs.
GetRawPtr();
584 for (
int i = 0; i < ldim; ++i)
586 r_buf[i] = lhs_buf[i] - rhs_buf[i];
590template <
typename ResultDataType,
typename InputDataType>
595 ResultDataType *r_buf = result.
GetRawPtr();
596 typename std::add_const<InputDataType>::type *lhs_buf = lhs.
GetRawPtr();
597 typename std::add_const<InputDataType>::type *rhs_buf = rhs.
GetRawPtr();
599 for (
int i = 0; i < ldim; ++i)
601 r_buf[i] = -lhs_buf[i] - rhs_buf[i];
621template <
typename ResultDataType,
typename InputDataType>
625 ResultDataType *r_buf = result.
GetRawPtr();
626 typename std::add_const<InputDataType>::type *rhs_buf = rhs.
GetRawPtr();
628 for (
int i = 0; i < rdim; ++i)
630 r_buf[i] -= rhs_buf[i];
634template <
typename ResultDataType,
typename InputDataType>
638 ResultDataType *r_buf = result.
GetRawPtr();
639 typename std::add_const<InputDataType>::type *rhs_buf = rhs.
GetRawPtr();
641 for (
int i = 0; i < rdim; ++i)
643 r_buf[i] = -r_buf[i] - rhs_buf[i];
659template <
typename DataType>
674template <
typename ResultDataType,
typename InputDataType>
678 ResultDataType *r_buf = result.
GetRawPtr();
679 typename std::add_const<InputDataType>::type *lhs_buf = lhs.
GetRawPtr();
682 for (
int i = 0; i < ldim; ++i)
684 r_buf[i] = lhs_buf[i] / rhs;
688template <
typename ResultDataType,
typename InputDataType>
692 ResultDataType *r_buf = result.
GetRawPtr();
693 typename std::add_const<InputDataType>::type *lhs_buf = lhs.
GetRawPtr();
696 for (
int i = 0; i < ldim; ++i)
698 r_buf[i] = lhs_buf[i] / rhs;
710template <
typename ResultDataType>
713 ResultDataType *r_buf = result.
GetRawPtr();
716 for (
int i = 0; i < resdim; ++i)
722template <
typename ResultDataType>
725 ResultDataType *r_buf = result.
GetRawPtr();
728 for (
int i = 0; i < resdim; ++i)
740template <
typename DataType>
748template <
typename DataType>
762template <
typename ResultDataType,
typename InputDataType>
767 ResultDataType *result_buf = result.
GetRawPtr();
768 const InputDataType *rhs_buf = rhs.
GetRawPtr();
769 const InputDataType *lhs_buf = lhs.
GetRawPtr();
771 for (
int i = 0; i < resdim; ++i)
773 result_buf[i] = lhs_buf[i] * rhs_buf[i];
785template <
typename ResultDataType,
typename InputDataType>
789 ResultDataType *result_buf = result.
GetRawPtr();
790 const InputDataType *rhs_buf = rhs.
GetRawPtr();
792 for (
int i = 0; i < resdim; ++i)
794 result_buf[i] *= rhs_buf[i];
804template <
typename DataType,
typename InputDataType>
819template <
typename ResultDataType,
typename InputDataType>
823 ResultDataType *r_buf = result.
GetRawPtr();
824 const InputDataType *lhs_buf = lhs.
GetRawPtr();
827 for (
int i = 0; i < ldim; ++i)
829 r_buf[i] = lhs_buf[i] * rhs;
833template <
typename ResultDataType,
typename InputDataType>
837 ResultDataType *r_buf = result.
GetRawPtr();
838 const InputDataType *lhs_buf = lhs.
GetRawPtr();
841 for (
int i = 0; i < ldim; ++i)
843 r_buf[i] = lhs_buf[i] * rhs;
855template <
typename ResultDataType>
858 ResultDataType *r_buf = result.
GetRawPtr();
860 for (
unsigned int i = 0; i < rdim; ++i)
866template <
typename ResultDataType>
869 ResultDataType *r_buf = result.
GetRawPtr();
871 for (
unsigned int i = 0; i < rdim; ++i)
882template <
typename DataType>
891template <
typename DataType>
906template <
typename ResultDataType,
typename InputDataType>
913template <
typename ResultDataType,
typename InputDataType>
918 ResultDataType *r_buf = result.
GetRawPtr();
919 const InputDataType *rhs_buf = rhs.
GetRawPtr();
923 for (
int i = 0; i < rdim; ++i)
925 r_buf[i] = inverse * rhs_buf[i];
929template <
typename ResultDataType,
typename InputDataType>
936template <
typename ResultDataType,
typename InputDataType>
941 ResultDataType *r_buf = result.
GetRawPtr();
942 const InputDataType *rhs_buf = rhs.
GetRawPtr();
946 for (
int i = 0; i < rdim; ++i)
948 r_buf[i] = inverse * rhs_buf[i];
968template <
typename DataType>
981template <
typename DataType>
994template <
typename DataType>
999 for (
unsigned int i = 0; i < 3; ++i)
1001 result[i] = dest[i] - source[i];
1012template <
typename DataType>
1017 for (
unsigned int i = 0; i < 3; ++i)
1019 result[i] = lhs[i] * t;
1031template <
typename DataType>
1048template <
typename DataType>
1051 return !(lhs == rhs);
1060template <
typename DataType>
1063 std::vector<DataType> result;
1067 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
1068 boost::char_separator<char> sep(
"(<,>) ");
1069 tokenizer tokens(str, sep);
1070 for (tokenizer::iterator strIter = tokens.begin();
1071 strIter != tokens.end(); ++strIter)
1073 result.push_back(boost::lexical_cast<DataType>(*strIter));
1076 catch (boost::bad_lexical_cast &)
1084 const std::string &str);
1087 const std::string &str);
1094 for (
typename VectorType::const_iterator iter = v.
begin(); iter != v.
end();
1097 result += fabs(*iter);
1112 for (
typename VectorType::const_iterator iter = v.
begin(); iter != v.
end();
1115 DataType
w = fabs(*iter);
1118 return sqrt(result);
1127 DataType result = fabs(v[0]);
1129 for (
unsigned int i = 0; i < vdim; ++i)
1131 result = std::max(DataType(fabs(v[i])), result);
1142template <
typename DataType>
1147 for (
unsigned int i = 0; i < tdim; ++i)
1164 for (
unsigned int i = 0; i < vdim; ++i)
1176 DataType result = DataType(0);
1179 for (
unsigned int i = 0; i < vdim; ++i)
1181 result += v[i] * v[i];
1183 return sqrt(result);
1192template <
typename DataType>
1196 "Dot, dimension of the two operands must be identical.");
1198 DataType result = DataType(0);
1200 for (
unsigned int i = 0; i < ldim; ++i)
1202 result += lhs[i] * rhs[i];
1217 if (m > DataType(0))
1245template <
typename DataType>
1250 "Cross is only valid for 3D vectors.");
1252 DataType first = lhs.
y() * rhs.
z() - lhs.
z() * rhs.
y();
1253 DataType second = lhs.
z() * rhs.
x() - lhs.
x() * rhs.
z();
1254 DataType third = lhs.
x() * rhs.
y() - lhs.
y() * rhs.
x();
1269 std::string result =
"(";
1270 for (
unsigned int i = 0; i <
d; ++i)
1272 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
bool operator==(const VertexSharedPtr &v1, const VertexSharedPtr &v2)
Define comparison operator for the vertex struct.
Array< OneD, constDataType >::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()
unsigned int GetDimension() const
Returns the number of dimensions for the point.
Array< OneD, DataType > m_data
unsigned int GetRows() const
std::string AsString() const
boost::call_traits< DataType >::reference y()
const DataType * const_iterator
DataType Magnitude() const
NekVector()
Creates an empty vector.
boost::call_traits< DataType >::reference z()
std::vector< double > w(NPUPPER)
std::vector< double > z(NPUPPER)
std::vector< double > d(NPUPPER *NPUPPER)
template NekVector< NekSingle > Divide(const NekVector< NekSingle > &lhs, const NekSingle &rhs)
void Normalize(NekVector< DataType > &v)
template NekVector< NekSingle > Multiply(const NekSingle &lhs, const NekVector< NekSingle > &rhs)
template NekSingle L2Norm(const NekVector< NekSingle > &v)
template NekSingle Dot(const NekVector< NekSingle > &lhs, const NekVector< NekSingle > &rhs)
std::string AsString(const NekVector< DataType > &v)
template void SubtractNegatedLhs(NekVector< NekSingle > &result, const NekVector< NekSingle > &lhs, const NekVector< NekSingle > &rhs)
template std::string AsString(const NekVector< NekSingle > &v)
NekMatrix< typename NekMatrix< LhsDataType, LhsMatrixType >::NumberType, StandardMatrixTag > operator-(const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
template void AddEqualNegatedLhs(NekVector< NekSingle > &result, const NekVector< NekSingle > &rhs)
template NekPoint< NekSingle > findPointAlongVector(const NekVector< NekSingle > &lhs, const NekSingle &t)
template NekVector< NekSingle > Subtract(const NekVector< NekSingle > &lhs, const NekVector< NekSingle > &rhs)
template void SubtractEqual(NekVector< NekSingle > &result, const NekVector< NekSingle > &rhs)
DataType InfinityNorm(const NekVector< DataType > &v)
void NegateInPlace(NekSingle &v)
template void AddNegatedLhs(NekVector< NekSingle > &result, const NekVector< NekSingle > &lhs, const NekVector< NekSingle > &rhs)
template void Normalize(NekVector< NekSingle > &v)
template void MultiplyEqual(NekVector< NekSingle > &result, const NekSingle &rhs)
template NekVector< NekSingle > Cross(const NekVector< NekSingle > &lhs, const NekVector< NekSingle > &rhs)
template NekVector< NekSingle > Negate(const NekVector< NekSingle > &v)
template NekVector< NekSingle > createVectorFromPoints(const NekPoint< NekSingle > &source, const NekPoint< NekSingle > &dest)
template NekSingle L1Norm(const NekVector< NekSingle > &v)
void InvertInPlace(NekSingle &v)
template void MultiplyInvertedLhs(NekVector< NekSingle > &result, const NekSingle &lhs, const NekVector< NekSingle > &rhs)
template void SubtractEqualNegatedLhs(NekVector< NekSingle > &result, const NekVector< NekSingle > &rhs)
DataType Magnitude(const NekVector< DataType > &v)
template std::ostream & operator<<(std::ostream &os, const NekVector< NekSingle > &rhs)
NekVector< DataType > Cross(const NekVector< DataType > &lhs, const NekVector< DataType > &rhs)
template void DivideEqual(NekVector< NekSingle > &result, const NekSingle &rhs)
template NekSingle InfinityNorm(const NekVector< NekSingle > &v)
DataType L2Norm(const NekVector< DataType > &v)
template std::vector< NekDouble > FromString(const std::string &str)
DataType L1Norm(const NekVector< DataType > &v)
template NekVector< NekSingle > Add(const NekVector< NekSingle > &lhs, const NekVector< NekSingle > &rhs)
template bool operator!=(const NekVector< NekSingle > &lhs, const NekVector< NekSingle > &rhs)
template void AddEqual(NekVector< NekSingle > &result, const NekVector< NekSingle > &rhs)
PointerWrapper
Specifies if the pointer passed to a NekMatrix or NekVector is copied into an internal representation...
DataType Dot(const NekVector< DataType > &lhs, const NekVector< DataType > &rhs)
void CopyArray(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest)
template NekSingle Magnitude(const NekVector< NekSingle > &v)
scalarT< T > sqrt(scalarT< T > in)