42 #ifndef SACADO_MP_VECTOR_SFS_HPP 43 #define SACADO_MP_VECTOR_SFS_HPP 47 #ifdef HAVE_STOKHOS_SACADO 57 template <
typename ordinal_t,
typename value_t,
int Num,
typename device_t>
58 class Vector<
Stokhos::StaticFixedStorage<ordinal_t,value_t,Num,device_t> >{
69 typedef typename storage_type::volatile_pointer volatile_pointer;
71 typedef typename storage_type::const_volatile_pointer const_volatile_pointer;
73 typedef typename storage_type::volatile_reference volatile_reference;
75 typedef typename storage_type::const_volatile_reference const_volatile_reference;
78 typedef typename ScalarType<value_type>::type
scalar_type;
81 template <
class NewStorageType >
83 typedef Vector< NewStorageType > type;
90 KOKKOS_INLINE_FUNCTION
97 KOKKOS_INLINE_FUNCTION
105 KOKKOS_INLINE_FUNCTION
106 Vector(
ordinal_type sz, pointer v,
bool owned) : s(sz,v,owned) {}
112 KOKKOS_INLINE_FUNCTION
116 KOKKOS_INLINE_FUNCTION
120 KOKKOS_INLINE_FUNCTION
121 Vector(
const Vector&
x) : s(
x.s) {}
124 KOKKOS_INLINE_FUNCTION
125 Vector(
const volatile Vector&
x) : s(
x.s) {}
128 KOKKOS_INLINE_FUNCTION
132 KOKKOS_INLINE_FUNCTION
136 KOKKOS_INLINE_FUNCTION
137 void init(
const value_type& v)
volatile { s.init(v); }
140 KOKKOS_INLINE_FUNCTION
144 KOKKOS_INLINE_FUNCTION
145 void init(
const value_type* v)
volatile { s.init(v); }
148 template <
typename S>
149 KOKKOS_INLINE_FUNCTION
150 void init(
const Vector<S>& v) {
151 s.init(v.s.coeff(), v.s.size());
155 template <
typename S>
156 KOKKOS_INLINE_FUNCTION
157 void init(
const Vector<S>& v)
volatile {
158 s.init(v.s.coeff(), v.s.size());
162 KOKKOS_INLINE_FUNCTION
166 KOKKOS_INLINE_FUNCTION
167 void load(
value_type* v)
volatile { s.load(v); }
170 template <
typename S>
171 KOKKOS_INLINE_FUNCTION
172 void load(Vector<S>& v) { s.load(v.s.coeff()); }
175 template <
typename S>
176 KOKKOS_INLINE_FUNCTION
177 void load(Vector<S>& v)
volatile { s.load(v.s.coeff()); }
183 KOKKOS_INLINE_FUNCTION
190 KOKKOS_INLINE_FUNCTION
203 KOKKOS_INLINE_FUNCTION
204 void copyForWrite()
volatile { }
207 template <
typename S>
208 KOKKOS_INLINE_FUNCTION
209 bool isEqualTo(
const Expr<S>& xx)
const {
210 const typename Expr<S>::derived_type&
x = xx.derived();
211 typedef IsEqual<value_type> IE;
214 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
219 template <
typename S>
220 KOKKOS_INLINE_FUNCTION
221 bool isEqualTo(
const Expr<S>& xx)
const volatile {
222 const typename Expr<S>::derived_type&
x = xx.derived();
223 typedef IsEqual<value_type> IE;
226 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
236 KOKKOS_INLINE_FUNCTION
243 KOKKOS_INLINE_FUNCTION
246 return const_cast<Vector&
>(*this);
250 KOKKOS_INLINE_FUNCTION
251 Vector& operator=(
const Vector&
x) {
260 KOKKOS_INLINE_FUNCTION
261 Vector& operator=(
const volatile Vector&
x) {
270 KOKKOS_INLINE_FUNCTION
271 Vector& operator=(
const Vector&
x)
volatile {
276 return const_cast<Vector&
>(*this);
280 KOKKOS_INLINE_FUNCTION
281 Vector& operator=(
const volatile Vector&
x)
volatile {
286 return const_cast<Vector&
>(*this);
295 KOKKOS_INLINE_FUNCTION
297 const volatile storage_type& storage()
const volatile {
return s; }
300 KOKKOS_INLINE_FUNCTION
304 KOKKOS_INLINE_FUNCTION
308 KOKKOS_INLINE_FUNCTION
317 KOKKOS_INLINE_FUNCTION
318 const_volatile_reference
val()
const volatile {
return s[0]; }
321 KOKKOS_INLINE_FUNCTION
322 const_reference
val()
const {
return s[0]; }
325 KOKKOS_INLINE_FUNCTION
326 volatile_reference
val()
volatile {
return s[0]; }
329 KOKKOS_INLINE_FUNCTION
330 reference
val() {
return s[0]; }
340 KOKKOS_INLINE_FUNCTION
344 KOKKOS_INLINE_FUNCTION
345 static bool hasFastAccess(
ordinal_type sz) {
return true; }
348 KOKKOS_INLINE_FUNCTION
349 const_pointer coeff()
const {
return s.coeff();}
352 KOKKOS_INLINE_FUNCTION
353 const_volatile_pointer coeff()
const volatile {
return s.coeff();}
356 KOKKOS_INLINE_FUNCTION
357 volatile_pointer coeff()
volatile {
return s.coeff();}
360 KOKKOS_INLINE_FUNCTION
361 pointer coeff() {
return s.coeff();}
364 KOKKOS_INLINE_FUNCTION
368 KOKKOS_INLINE_FUNCTION
372 KOKKOS_INLINE_FUNCTION
376 KOKKOS_INLINE_FUNCTION
380 KOKKOS_INLINE_FUNCTION
381 const_volatile_reference fastAccessCoeff(
ordinal_type i)
const volatile {
385 KOKKOS_INLINE_FUNCTION
390 KOKKOS_INLINE_FUNCTION
391 volatile_reference fastAccessCoeff(
ordinal_type i)
volatile {
395 KOKKOS_INLINE_FUNCTION
407 KOKKOS_INLINE_FUNCTION
415 KOKKOS_INLINE_FUNCTION
416 Vector& operator += (
const volatile value_type&
x) {
423 KOKKOS_INLINE_FUNCTION
424 Vector& operator += (
const value_type&
x)
volatile {
427 return const_cast<Vector&
>(*this);
431 KOKKOS_INLINE_FUNCTION
432 Vector& operator += (
const volatile value_type&
x)
volatile {
435 return const_cast<Vector&
>(*this);
439 KOKKOS_INLINE_FUNCTION
447 KOKKOS_INLINE_FUNCTION
448 Vector& operator -= (
const volatile value_type&
x) {
455 KOKKOS_INLINE_FUNCTION
456 Vector& operator -= (
const value_type&
x)
volatile {
459 return const_cast<Vector&
>(*this);
463 KOKKOS_INLINE_FUNCTION
464 Vector& operator -= (
const volatile value_type&
x)
volatile {
467 return const_cast<Vector&
>(*this);
471 KOKKOS_INLINE_FUNCTION
479 KOKKOS_INLINE_FUNCTION
480 Vector& operator *= (
const volatile value_type&
x) {
487 KOKKOS_INLINE_FUNCTION
488 Vector& operator *= (
const value_type&
x)
volatile {
491 return const_cast<Vector&
>(*this);
495 KOKKOS_INLINE_FUNCTION
496 Vector& operator *= (
const volatile value_type&
x)
volatile {
499 return const_cast<Vector&
>(*this);
503 KOKKOS_INLINE_FUNCTION
511 KOKKOS_INLINE_FUNCTION
512 Vector& operator /= (
const volatile value_type&
x) {
519 KOKKOS_INLINE_FUNCTION
520 Vector& operator /= (
const value_type&
x)
volatile {
523 return const_cast<Vector&
>(*this);
527 KOKKOS_INLINE_FUNCTION
528 Vector& operator /= (
const volatile value_type&
x)
volatile {
531 return const_cast<Vector&
>(*this);
535 KOKKOS_INLINE_FUNCTION
536 Vector& operator += (
const Vector&
x) {
538 s[i] +=
x.fastAccessCoeff(i);
543 KOKKOS_INLINE_FUNCTION
544 Vector& operator += (
const volatile Vector&
x) {
550 KOKKOS_INLINE_FUNCTION
551 Vector& operator += (
const Vector&
x)
volatile {
553 return const_cast<Vector&
>(*this);
557 KOKKOS_INLINE_FUNCTION
558 Vector& operator += (
const volatile Vector&
x)
volatile {
560 return const_cast<Vector&
>(*this);
564 KOKKOS_INLINE_FUNCTION
565 Vector& operator -= (
const Vector&
x) {
571 KOKKOS_INLINE_FUNCTION
572 Vector& operator -= (
const volatile Vector&
x) {
578 KOKKOS_INLINE_FUNCTION
579 Vector& operator -= (
const Vector&
x)
volatile {
581 return const_cast<Vector&
>(*this);
585 KOKKOS_INLINE_FUNCTION
586 Vector& operator -= (
const volatile Vector&
x)
volatile {
588 return const_cast<Vector&
>(*this);
592 KOKKOS_INLINE_FUNCTION
593 Vector& operator *= (
const Vector&
x) {
599 KOKKOS_INLINE_FUNCTION
600 Vector& operator *= (
const volatile Vector&
x) {
606 KOKKOS_INLINE_FUNCTION
607 Vector& operator *= (
const Vector&
x)
volatile {
609 return const_cast<Vector&
>(*this);
613 KOKKOS_INLINE_FUNCTION
614 Vector& operator *= (
const volatile Vector&
x)
volatile {
616 return const_cast<Vector&
>(*this);
620 KOKKOS_INLINE_FUNCTION
621 Vector& operator /= (
const Vector&
x) {
627 KOKKOS_INLINE_FUNCTION
628 Vector& operator /= (
const volatile Vector&
x) {
634 KOKKOS_INLINE_FUNCTION
635 Vector& operator /= (
const Vector&
x)
volatile {
637 return const_cast<Vector&
>(*this);
641 KOKKOS_INLINE_FUNCTION
642 Vector& operator /= (
const volatile Vector&
x)
volatile {
644 return const_cast<Vector&
>(*this);
648 KOKKOS_INLINE_FUNCTION
649 Vector& operator++() {
656 KOKKOS_INLINE_FUNCTION
657 volatile Vector& operator++()
volatile {
664 KOKKOS_INLINE_FUNCTION
665 Vector operator++(
int) {
672 KOKKOS_INLINE_FUNCTION
673 Vector operator++(
int)
volatile {
680 KOKKOS_INLINE_FUNCTION
681 Vector& operator--() {
688 KOKKOS_INLINE_FUNCTION
689 volatile Vector& operator--()
volatile {
696 KOKKOS_INLINE_FUNCTION
697 Vector operator--(
int) {
704 KOKKOS_INLINE_FUNCTION
705 Vector operator--(
int)
volatile {
713 KOKKOS_INLINE_FUNCTION
714 std::string name()
const volatile {
return "x"; }
731 #endif // HAVE_STOKHOS_SACADO 733 #endif // SACADO_MP_VECTOR_SFS_HPP
Stokhos::StandardStorage< int, double > storage_type
Stokhos::StandardStorage< int, double > Storage
const double & const_reference
Statically allocated storage class.
Kokkos::DefaultExecutionSpace execution_space
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
const double * const_pointer
Top-level namespace for Stokhos classes and functions.
int size() const
Return size.