Menu

[r124]: / trunk / include / small / drovector_small-function.hpp  Maximize  Restore  History

Download this file

105 lines (97 with data), 2.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
//=============================================================================
/*! */
template<long n>
inline dcovector_small<n> t(const drovector_small<n>& A)
{
dcovector_small<n> X;
for(long i=0; i<n; i++){
X(i)=A(i);
}
return X;
}
//=============================================================================
/*! */
template<long n>
inline drovector_small<n> operator*(const drovector_small<n>& A, const double& v)
{
drovector_small<n> C;
for(long i=0; i<n; i++){
C(i) =A(i)*v;
}
return C;
}
//=============================================================================
/*! */
template<long n>
inline drovector_small<n> operator/(const drovector_small<n>& A, const double& v)
{
drovector_small<n> C;
for(long i=0; i<n; i++){
C(i) =A(i)/v;
}
return C;
}
//=============================================================================
template<long l>
inline double& drovector_small<l>::operator()(const long& k)
{
return array[k];
}
//=============================================================================
template<long l>
inline double drovector_small<l>::operator()(const long& k) const
{
return array[k];
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
template<long l>
inline std::ostream& operator<<(std::ostream& s, const drovector_small<l>& A)
{
s << std::setiosflags(std::ios::showpos);
for(long i=0; i<l; i++){
s << " " << A(i) << std::flush;
}
s << std::endl;
return s;
}
//=============================================================================
/*! */
template<long l>
inline drovector_small<l> operator+(const drovector_small<l>& A)
{
drovector_small<l> X;
for(long i=0; i<l; i++){
X(i)=A(i);
}
return X;
}
//=============================================================================
/*! */
template<long l>
inline drovector_small<l> operator-(const drovector_small<l>& A)
{
drovector_small<l> X;
for(long i=0; i<l; i++){
X(i)=-A(i);
}
return X;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
/*! */
template<long m, long n>
inline drovector_small<n> operator*(const drovector_small<m>& A, const dgematrix_small<m,n>& B)
{
drovector_small<n> C(0.);
for(long j=0; j<n; j++){
for(long i=0; i<m; i++){
C(j) +=A(i)*B(i,j);
}
}
return C;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.