43 template<
typename DataType>
51 template<
typename DataType>
59 template<
typename DataType>
68 template<
typename DataType>
76 std::vector<DataType> values = FromString<DataType>(vectorValues);
79 std::copy(values.begin(), values.end(),
m_data.
begin());
81 ASSERTL0(m_size > 0,
"Error converting string values to vector");
83 catch(std::runtime_error& e)
89 template<
typename DataType>
91 typename boost::call_traits<DataType>::const_reference y,
92 typename boost::call_traits<DataType>::const_reference z) :
102 template<
typename DataType>
104 m_size(rhs.GetDimension()),
106 m_wrapperType(rhs.m_wrapperType)
115 template<
typename DataType>
123 template<
typename DataType>
125 m_size(ptr.num_elements()),
136 template<
typename DataType>
145 boost::lexical_cast<std::string>(size) +
" but the incoming array only has " +
146 boost::lexical_cast<std::string>(ptr.
num_elements()) +
" elements.");
153 template<
typename DataType>
155 m_size(ptr.num_elements()),
166 template<
typename DataType>
175 boost::lexical_cast<std::string>(size) +
" but the incoming array only has " +
176 boost::lexical_cast<std::string>(ptr.
num_elements()) +
" elements.");
183 template<
typename DataType>
186 template<
typename DataType>
189 if( m_wrapperType ==
eCopy )
199 else if( m_wrapperType ==
eWrapper )
203 ASSERTL0(GetDimension() == rhs.
GetDimension(),
"Wrapped NekVectors must have the same dimension in operator=");
206 std::copy(rhs.
begin(), rhs.
end(), m_data.get());
211 template<
typename DataType>
217 template<
typename DataType>
223 template<
typename DataType>
226 return this->GetData().get();
229 template<
typename DataType>
232 template<
typename DataType>
238 template<
typename DataType>
241 template<
typename DataType>
244 template<
typename DataType>
247 template<
typename DataType>
250 template<
typename DataType>
253 template<
typename DataType>
256 ASSERTL1((i >= 0) && (i < this->GetDimension()),
"Invalid access to m_data via parenthesis operator");
257 return this->GetData()[i];
260 template<
typename DataType>
263 return this->GetData()[i];
266 template<
typename DataType>
269 ASSERTL1(this->GetDimension() >= 1,
"Invalid use of NekVector::x");
273 template<
typename DataType>
276 ASSERTL1(this->GetDimension() >= 2,
"Invalid use of NekVector::y");
280 template<
typename DataType>
283 ASSERTL1(this->GetDimension() >= 3,
"Invalid use of NekVector::z");
287 template<
typename DataType>
290 ASSERTL1(this->GetDimension() >= 1,
"Invalid use of NekVector::SetX");
291 this->GetData()[0] = val;
294 template<
typename DataType>
297 ASSERTL1(this->GetDimension() >= 2,
"Invalid use of NekVector::SetX");
298 this->GetData()[1] = val;
301 template<
typename DataType>
304 ASSERTL1(this->GetDimension() >= 3,
"Invalid use of NekVector::SetX");
305 this->GetData()[2] = val;
308 template<
typename DataType>
315 template<
typename DataType>
322 template<
typename DataType>
329 template<
typename DataType>
336 template<
typename DataType>
339 template<
typename DataType>
342 ASSERTL1(( i >= 0) && (i < GetDimension()),
"Invalid access to m_data via parenthesis operator");
346 template<
typename DataType>
352 template<
typename DataType>
355 ASSERTL1( GetDimension() >= 1,
"Invalid use of NekVector::x");
359 template<
typename DataType>
362 ASSERTL1( GetDimension() >= 2,
"Invalid use of NekVector::y");
366 template<
typename DataType>
369 ASSERTL1( GetDimension() >= 3,
"Invalid use of NekVector::z");
373 #ifndef NEKTAR_USE_EXPRESSION_TEMPLATES
374 template<
typename DataType>
378 template<
typename DataType>
381 template<
typename DataType>
384 template<
typename DataType>
390 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 template<
typename DataType>
421 if(m_data.num_elements() < newSize )
430 template<
typename DataType>
436 const DataType* lhs_buf = lhs.
GetRawPtr();
437 const DataType* rhs_buf = rhs.
GetRawPtr();
439 for(
int i = 0; i < ldim; ++i)
441 r_buf[i] = lhs_buf[i] + rhs_buf[i];
445 template<
typename DataType>
451 const DataType* lhs_buf = lhs.
GetRawPtr();
452 const DataType* rhs_buf = rhs.
GetRawPtr();
454 for(
int i = 0; i < ldim; ++i)
456 r_buf[i] = -lhs_buf[i] + rhs_buf[i];
461 const NekVector<NekDouble>&
lhs,
462 const NekVector<NekDouble>& rhs);
464 const NekVector<NekDouble>&
lhs,
465 const NekVector<NekDouble>& rhs);
467 template<
typename DataType>
472 const DataType* rhs_buf = rhs.
GetRawPtr();
474 for(
int i = 0; i < rdim; ++i)
476 r_buf[i] += rhs_buf[i];
480 template<
typename DataType>
485 const DataType* rhs_buf = rhs.
GetRawPtr();
487 for(
int i = 0; i < rdim; ++i)
489 r_buf[i] = -r_buf[i] + rhs_buf[i];
494 void AddEqual(NekVector<NekDouble>& result,
495 const NekVector<NekDouble>& rhs);
498 const NekVector<NekDouble>& rhs);
506 Add(result, lhs, rhs);
511 NekVector<NekDouble>
Add(
const NekVector<NekDouble>&
lhs,
512 const NekVector<NekDouble>& rhs);
514 template<
typename ResultDataType,
typename InputDataType>
519 ResultDataType* r_buf = result.
GetRawPtr();
520 typename boost::add_const<InputDataType>::type* lhs_buf = lhs.
GetRawPtr();
521 typename boost::add_const<InputDataType>::type* rhs_buf = rhs.
GetRawPtr();
523 for(
int i = 0; i < ldim; ++i)
525 r_buf[i] = lhs_buf[i] - rhs_buf[i];
529 template<
typename ResultDataType,
typename InputDataType>
534 ResultDataType* r_buf = result.
GetRawPtr();
535 typename boost::add_const<InputDataType>::type* lhs_buf = lhs.
GetRawPtr();
536 typename boost::add_const<InputDataType>::type* rhs_buf = rhs.
GetRawPtr();
538 for(
int i = 0; i < ldim; ++i)
540 r_buf[i] = -lhs_buf[i] - rhs_buf[i];
545 void Subtract(NekVector<NekDouble>& result,
546 const NekVector<NekDouble>&
lhs,
547 const NekVector<NekDouble>& rhs);
551 const NekVector<NekDouble>&
lhs,
552 const NekVector<NekDouble>& rhs);
554 template<
typename ResultDataType,
typename InputDataType>
558 ResultDataType* r_buf = result.
GetRawPtr();
559 typename boost::add_const<InputDataType>::type* rhs_buf = rhs.
GetRawPtr();
561 for(
int i = 0; i < rdim; ++i)
563 r_buf[i] -= rhs_buf[i];
567 template<
typename ResultDataType,
typename InputDataType>
571 ResultDataType* r_buf = result.
GetRawPtr();
572 typename boost::add_const<InputDataType>::type* rhs_buf = rhs.
GetRawPtr();
574 for(
int i = 0; i < rdim; ++i)
576 r_buf[i] = -r_buf[i] - rhs_buf[i];
582 const NekVector<NekDouble>& rhs);
586 const NekVector<NekDouble>& rhs);
588 template<
typename DataType>
601 const NekVector<NekDouble>& rhs);
603 template<
typename ResultDataType,
typename InputDataType>
608 ResultDataType* r_buf = result.
GetRawPtr();
609 typename boost::add_const<InputDataType>::type* lhs_buf = lhs.
GetRawPtr();
612 for(
int i = 0; i < ldim; ++i)
614 r_buf[i] = lhs_buf[i] / rhs;
619 void Divide(NekVector<NekDouble>& result,
620 const NekVector<NekDouble>&
lhs,
623 template<
typename ResultDataType>
627 ResultDataType* r_buf = result.
GetRawPtr();
630 for(
int i = 0; i < resdim; ++i)
640 template<
typename DataType>
656 template<
typename ResultDataType,
typename InputDataType>
661 ResultDataType* result_buf = result.
GetRawPtr();
662 const InputDataType* rhs_buf = rhs.
GetRawPtr();
663 const InputDataType* lhs_buf = lhs.
GetRawPtr();
665 for(
int i = 0; i < resdim; ++i)
667 result_buf[i] = lhs_buf[i] * rhs_buf[i];
672 void Multiply(NekVector<NekDouble>& result,
const NekVector<NekDouble>&
lhs,
const NekVector<NekDouble>& rhs);
674 template<
typename ResultDataType,
typename InputDataType>
678 ResultDataType* result_buf = result.
GetRawPtr();
679 const InputDataType* rhs_buf = rhs.
GetRawPtr();
681 for(
int i = 0; i < resdim; ++i)
683 result_buf[i] *= rhs_buf[i];
688 void MultiplyEqual(NekVector<NekDouble>& result,
const NekVector<NekDouble>& rhs);
690 template<
typename DataType,
typename InputDataType>
702 Multiply(
const NekVector<NekDouble>&
lhs,
const NekVector<NekDouble>& rhs);
705 template<
typename ResultDataType,
typename InputDataType>
710 ResultDataType* r_buf = result.
GetRawPtr();
711 const InputDataType* lhs_buf = lhs.
GetRawPtr();
714 for(
int i = 0; i < ldim; ++i)
716 r_buf[i] = lhs_buf[i] * rhs;
721 void Multiply(NekVector<NekDouble>& result,
722 const NekVector<NekDouble>&
lhs,
725 template<
typename ResultDataType>
729 ResultDataType* r_buf = result.
GetRawPtr();
731 for(
unsigned int i = 0; i < rdim; ++i)
740 template<
typename DataType>
755 template<
typename ResultDataType,
typename InputDataType>
763 template<
typename ResultDataType,
typename InputDataType>
768 ResultDataType* r_buf = result.
GetRawPtr();
769 const InputDataType* rhs_buf = rhs.
GetRawPtr();
773 for(
int i = 0; i < rdim; ++i)
775 r_buf[i] = inverse * rhs_buf[i];
782 const NekVector<NekDouble>& rhs);
785 void Multiply(NekVector<NekDouble>& result,
787 const NekVector<NekDouble>& rhs);
789 template<
typename DataType>
798 const NekVector<NekDouble>& rhs);
801 template<
typename DataType>
802 std::ostream& operator<<(std::ostream& os, const NekVector<DataType>& rhs)
804 os << rhs.AsString();
809 std::ostream& operator<<(std::ostream& os, const NekVector<NekDouble>& rhs);
811 template<
typename DataType>
816 for(
unsigned int i = 0; i < 3; ++i)
818 result[i] = dest[i]-source[i];
826 const NekPoint<NekDouble>& dest);
828 template<
typename DataType>
833 for(
unsigned int i = 0; i < 3; ++i)
835 result[i] = lhs[i]*t;
845 template<
typename DataType>
859 const NekVector<NekDouble>& rhs);
861 template<
typename DataType>
865 return !(lhs == rhs);
870 const NekVector<NekDouble>& rhs);
872 template<
typename DataType>
875 std::vector<DataType> result;
879 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
880 boost::char_separator<char> sep(
"(<,>) ");
881 tokenizer tokens(str, sep);
884 result.push_back(boost::lexical_cast<DataType>(*strIter));
887 catch(boost::bad_lexical_cast&)
895 std::vector<NekDouble>
FromString(
const std::string& str);
897 template<
typename DataType>
903 for(
typename VectorType::const_iterator iter = v.
begin(); iter != v.
end(); ++iter)
905 result += fabs(*iter);
914 template<
typename DataType>
920 for(
typename VectorType::const_iterator iter = v.
begin(); iter != v.
end(); ++iter)
922 DataType v = fabs(*iter);
931 template<
typename DataType>
934 DataType result = fabs(v[0]);
936 for(
unsigned int i = 0; i < vdim; ++i)
938 result = std::max(fabs(v[i]), result);
946 template<
typename DataType>
951 for(
unsigned int i = 0; i < tdim; ++i)
959 NekVector<NekDouble>
Negate(
const NekVector<NekDouble>& v);
961 template<
typename DataType>
966 for(
unsigned int i = 0; i < vdim; ++i)
975 template<
typename DataType>
978 DataType result = DataType(0);
981 for(
unsigned int i = 0; i < vdim; ++i)
991 template<
typename DataType>
997 DataType result = DataType(0);
999 for(
unsigned int i = 0; i < ldim; ++i)
1001 result += lhs[i]*rhs[i];
1009 const NekVector<NekDouble>& rhs) ;
1011 template<
typename DataType>
1015 if( m > DataType(0) )
1022 void Normalize(NekVector<NekDouble>& v);
1027 template<
typename DataType>
1033 DataType first = lhs.
y()*rhs.
z() - lhs.
z()*rhs.
y();
1034 DataType second = lhs.
z()*rhs.
x() - lhs.
x()*rhs.
z();
1035 DataType third = lhs.
x()*rhs.
y() - lhs.
y()*rhs.
x();
1042 NekVector<NekDouble>
Cross(
const NekVector<NekDouble>&
lhs,
const NekVector<NekDouble>& rhs);
1044 template<
typename DataType>
1048 std::string result =
"(";
1049 for(
unsigned int i = 0; i < d; ++i)
1051 result += boost::lexical_cast<std::string>(v[i]);
1062 std::string
AsString(
const NekVector<NekDouble>& v);