42 #ifndef VECTOR_CLASS_TMPL_H
43 #define VECTOR_CLASS_TMPL_H
50 namespace DenseLinAlgPack{
121 #if defined(_INTEL_CXX) || defined (_INTEL_CXX)
792 , size, vs.
stride() * stride );
810 #ifndef LINALGPACK_CHECK_SLICE_SETUP
818 #ifndef LINALGPACK_CHECK_RANGE
824 #ifndef LINALGPACK_CHECK_RANGE
830 #ifndef LINALGPACK_CHECK_RHS_SIZES
836 namespace DenseLinAlgPack {
862 : ptr_( ptr + rng.lbound() - 1 )
872 : ptr_( vs.start_ptr() + (rng.lbound() - 1) * vs.stride() )
874 , stride_( vs.stride() )
890 {
return iterator(start_ptr(), stride()); }
895 {
return iterator(start_ptr() + dim() * stride(), stride()); }
905 {
return const_iterator(start_ptr() + dim() * stride(), stride()); }
933 return ptr_[(i-1)*stride_];
941 return ptr_[(i-1)*stride_];
949 return ptr_[(i)*stride_];
957 return ptr_[(i)*stride_];
994 {
return VectorSliceTmpl( start_ptr() + stride() * (dim()-1), dim(), - stride() ); }
999 {
return VectorSliceTmpl( const_cast<value_type*>(start_ptr()) + stride() * (dim()-1), dim(), - stride() ); }
1006 std::fill(begin(),end(),alpha);
1031 {
return stride() > 0 ? start_ptr() : start_ptr() + stride() * (dim() - 1); }
1036 {
return stride() > 0 ? start_ptr() : start_ptr() + stride() * (dim() - 1); }
1098 std::fill(begin(),end(),val);
1112 {
return v_.size(); }
1118 {
return start_ptr(); }
1123 {
return start_ptr() + dim(); }
1128 {
return start_ptr(); }
1133 {
return start_ptr() + dim(); }
1161 return start_ptr()[i-1];
1169 return start_ptr()[i-1];
1177 return start_ptr()[i];
1185 return start_ptr()[i];
1237 VectorTmpl<T>::operator
const VectorSliceTmpl<T>()
const
1238 {
return VectorSliceTmpl<T>(
const_cast<value_type*
>(start_ptr()), dim()); }
1245 if(!dim()) resize(1);
1246 std::fill(begin(),end(),alpha);
1273 {
return start_ptr(); }
1278 {
return start_ptr(); }
1283 {
return dim() ? &(v_)[0] : 0; }
1288 {
return &
const_cast<valarray&
>((v_))[0]; }
1303 *raw_ptr1 = ( stride() > 0 ? start_ptr() : start_ptr() + (dim()-1)*stride() ),
1313 if(raw_ptr1 > raw_ptr2) {
1319 if( raw_ptr1 + stride1 * (size1 - 1) < raw_ptr2 ) {
1325 start2 = raw_ptr2 - raw_ptr1;
1327 if(start1 == start2 && stride1 == stride2 && size1 == size2)
1333 else if(stride1 == stride2) {
1334 if(!((start2 - start1) % stride1))
1340 if(stride1 == 1 || stride2 == 1) {
1343 bool switch_them = (stride2 == 1);
1357 size_t max_rows = (start1+size1-1)/stride2 - start1/stride2 > 0 ? stride2 - 1 : stride2;
1360 size_t vs2_col_i = start1/max_rows - start2/max_rows;
1365 size_t vs2_col_rng = start2 + vs2_col_i * stride2;
1366 if(start1 <= vs2_col_rng && vs2_col_rng <= start1+size1-1)
1374 bool switch_them = stride2 < stride1;
1381 size_t max_rows = stride1;
1384 size_t sec_first_col = (start1 > start2) ? start1/max_rows : start2/max_rows,
1385 last1 = start1 + (size1 - 1) * stride1,
1386 last2 = start2 + (size2 - 1) * stride2,
1387 sec_last_col = (last1 < last2) ? last1/max_rows : last2/max_rows;
1390 size_t vs1_first_col = start1 / max_rows,
1391 vs2_first_col = start2 / max_rows;
1394 size_t vs1_first_col_i = sec_first_col - vs1_first_col,
1395 vs1_last_col_i = sec_last_col - vs1_first_col,
1396 vs2_first_col_i = sec_first_col - vs2_first_col,
1397 vs2_last_col_i = sec_last_col - vs2_first_col;
1403 ptrdiff_t diff1 = (start1 + vs1_first_col_i * stride1)
1404 - static_cast<ptrdiff_t>((start2 + vs2_first_col_i * stride2)),
1405 diff2 = (start1 + vs1_last_col_i * stride1)
1406 -
static_cast<ptrdiff_t
>((start2 + vs2_last_col_i * stride2));
1407 if(diff1 * diff2 > 0 )
1418 *raw_ptr1 = ( stride() > 0 ? start_ptr() : start_ptr() + (dim()-1)*stride() ),
1424 if( raw_ptr1 <= raw_ptr2 && raw_ptr2 + size2 <= raw_ptr1 + size1 ) {
1425 if( raw_ptr1 == raw_ptr2 && size1 == size2 && 1 == vs.
stride() )
1434 #endif // end VECTOR_CLASS_TMPL_H
std::reverse_iterator< const_iterator > const_reverse_iterator
Teuchos::Ordinal size_type
Typedef for the size type of elements that are used by the library.
AbstractLinAlgPack::size_type size_type
reverse_iterator rbegin()
std::reverse_iterator< iterator > reverse_iterator
size_type dim() const
Returns the number of elements of the VectorSliceTmpl.
reverse_iterator rbegin()
size_type vector_validate_sized(size_type size)
value_type * start_ptr()
Return a pointer to the conceptual first element in the underlying array.
ptrdiff_t difference_type
void abs(DVectorSlice *vs_lhs, const DVectorSlice &vs_rhs)
vs_lhs = abs(vs_rhs)
Index ubound() const
Return upper bound of the range.
value_type * start_ptr()
Return a pointer to the conceptual first element in the underlying array.
void resize(size_type n, value_type val=value_type())
VectorSliceTmpl< value_type > operator()()
EOverLap overlap(const VectorSliceTmpl< value_type > &vs) const
VectorTmpl()
Constructs a vector with 0 elements (this->dim()==0).
C++ Standard Library compatable iterator class for accesing nonunit stride arrays of data...
DenseLinAlgPack::size_type size_type
void assert_vs_sizes(size_type size1, size_type size2)
VectorSliceTmpl< value_type > * operator&()
Allow the address to be taken of an rvalue of this object.
value_type * raw_ptr()
Return a pointer to the address of the first memory location of underlying array. ...
const value_type & const_reference
VectorSliceTmpl< value_type > rev()
const value_type * const_iterator
. One-based subregion index range class.
void copy(const f_int &N, const f_dbl_prec *X, const f_int &INCX, f_dbl_prec *Y, const f_int &INCY)
VectorSliceTmpl< value_type > & operator=(value_type alpha)
StrideIterPack::stride_iter< value_type *, value_type, value_type &, value_type *, difference_type > iterator
value_type * raw_ptr()
Return a pointer to the address of the first memory location of underlying array. ...
bool full_range() const
Returns true if the range represents the entire region (constructed from Range1D()) ...
size_type dim() const
Returns the number of elements of the DVector.
VectorSliceTmpl< value_type > & operator()()
VectorSliceTmpl< T > gen_vs(VectorSliceTmpl< T > &vs, size_type start, size_type size, ptrdiff_t stride)
difference_type stride() const
Return the distance (+,-) (in units of elements) between adjacent elements in the underlying array...
StrideIterPack::stride_iter< const value_type *, value_type, const value_type &, const value_type *, difference_type > const_iterator
void bind(VectorSliceTmpl< value_type > vs)
Bind to the view of another VectorSliceTmpl.
std::reverse_iterator< iterator > reverse_iterator
const VectorSliceTmpl< value_type > * operator&() const
ptrdiff_t difference_type
EOverLap overlap(const VectorSliceTmpl< value_type > &vs) const
EOverLap
Enumeration for returning the amount of overlap between two objects.
const value_type & const_reference
void vector_validate_range(size_type ubound, size_type max_ubound)
DenseLinAlgPack::size_type size_type
const f_dbl_prec const f_int const f_int const f_int f_dbl_prec rhs[]
difference_type stride() const
Return the distance (+,-) (in units of elements) between adjacent elements in the underlying array...
std::reverse_iterator< const_iterator > const_reverse_iterator
FortranTypes::f_dbl_prec value_type
Typedef for the value type of elements that is used for the library.
void swap(row_col_value_type< T > &v1, row_col_value_type< T > &v2)
Swap row_col_value_type<T> objects.
reference operator[](size_type i)
1-based element access (lvalue)
void vector_validate_subscript(size_type size, size_type i)
reference operator[](size_type i)
1-based element access (lvalue)
RangePack::Range1D Range1D
std::vector< value_type > valarray
VectorSliceTmpl< value_type > rev()
VectorTmpl< value_type > & operator=(value_type alpha)