#include <yang.h>
List of all members.
Public Member Functions |
| Vtr (int, double *) |
| Vtr (int, double=0) |
| Vtr (const Vtr &) |
| ~Vtr () |
Vtr & | operator= (const Vtr &) |
Vtr & | operator+= (const Vtr &) |
Vtr & | operator-= (const Vtr &) |
double & | operator[] (int i) const |
double | maxnorm () const |
double | twonorm () const |
int | size () const |
Private Attributes |
int | lenth |
double * | ets |
Friends |
Vtr | operator+ (const Vtr &) |
Vtr | operator- (const Vtr &) |
Vtr | operator+ (const Vtr &, const Vtr &) |
Vtr | operator- (const Vtr &, const Vtr &) |
double | dot (const Vtr &, const Vtr &) |
Vtr | operator* (const double, const Vtr &) |
Vtr | operator* (const Vtr &, const double) |
Vtr | operator* (const Vtr &, const Vtr &) |
Vtr | operator* (const Vtr &, const Mtx &) |
Vtr | operator/ (const Vtr &, const double) |
std::ostream & | operator<< (std::ostream &, const Vtr &) |
Detailed Description
Definition at line 14 of file yang.h.
Constructor & Destructor Documentation
Vtr::Vtr |
( |
int |
n, |
|
|
double * |
abd | |
|
) |
| | |
Definition at line 18 of file yang.cc.
{
ets = new double [lenth =n];
for (int i = 0; i < lenth; i++) ets[i]= *(abd +i);
}
Vtr::Vtr |
( |
int |
n, |
|
|
double |
a = 0 | |
|
) |
| | |
Definition at line 23 of file yang.cc.
{
ets = new double [lenth =n];
for (int i = 0; i < lenth; i++) ets[i] = a;
}
Vtr::Vtr |
( |
const Vtr & |
v |
) |
|
Definition at line 28 of file yang.cc.
{
ets = new double [lenth = v.lenth];
for (int i = 0; i < lenth; i++) ets[i] = v[i];
}
Member Function Documentation
double Vtr::maxnorm |
( |
|
) |
const |
Definition at line 100 of file yang.cc.
{
double norm = std::abs(ets[0]);
for (int i = 1; i < lenth; i++)
if (norm < std::abs(ets[i])) norm = std::abs(ets[i]);
return norm;
}
Vtr & Vtr::operator+= |
( |
const Vtr & |
v |
) |
|
Vtr & Vtr::operator-= |
( |
const Vtr & |
v |
) |
|
Vtr & Vtr::operator= |
( |
const Vtr & |
v |
) |
|
Definition at line 37 of file yang.cc.
{
if (this != &v) {
if (lenth != v.lenth ) error("Vtr::op=: Error: Bad vector sizes");
for (int i = 0; i < lenth; i++) ets[i] = v[i];
}
return *this;
}
double& Vtr::operator[] |
( |
int |
i |
) |
const [inline] |
int Vtr::size |
( |
|
) |
const [inline] |
double Vtr::twonorm |
( |
|
) |
const |
Definition at line 87 of file yang.cc.
{
double norm = std::abs(ets[0]);
for (int i = 1; i < lenth; i++) {
double vi = std::abs(ets[i]);
if (norm < 100) norm = std::sqrt(norm*norm + vi*vi);
else {
double tm = vi/norm;
norm *= std::sqrt(1.0 + tm*tm);
}
}
return norm;
}
Friends And Related Function Documentation
double dot |
( |
const Vtr & |
v1, |
|
|
const Vtr & |
v2 | |
|
) |
| | [friend] |
Definition at line 127 of file yang.cc.
{
int sz = v1.lenth;
if (sz != v2.lenth ) error("bad vtor sizes");
double tm = v1[0]*v2[0];
for (int i = 1; i < sz; i++) tm += v1[i]*v2[i];
return tm;
}
Vtr operator* |
( |
const Vtr & |
v1, |
|
|
const Vtr & |
v2 | |
|
) |
| | [friend] |
Definition at line 113 of file yang.cc.
{
int sz = v1.lenth;
if (sz != v2.lenth ) error("bad vtor sizes");
Vtr tm(sz);
for (int i = 0; i < sz; i++)
tm[i] = v1[i]*v2[i];
return tm;
}
Vtr operator* |
( |
const Vtr & |
v, |
|
|
const Mtx & |
mat | |
|
) |
| | [friend] |
Definition at line 214 of file yang.cc.
{
if (v.lenth != mat.nrows)
error("op*(Vtr, Mtx): Error: Mat. and vec. size do no match.");
Vtr res(mat.ncols, 0.0);
for (int i=0; i<mat.ncols; i++)
for (int j=0; j<v.lenth; j++)
res[i] = v.ets[j] * mat.ets[j][i];
return res;
}
Vtr operator* |
( |
const double |
scalar, |
|
|
const Vtr & |
v | |
|
) |
| | [friend] |
Definition at line 107 of file yang.cc.
{
Vtr tm(v.lenth);
for (int i = 0; i < v.lenth; i++) tm[i] = scalar*v[i];
return tm;
}
Vtr operator* |
( |
const Vtr & |
v, |
|
|
const double |
scalar | |
|
) |
| | [friend] |
Vtr operator+ |
( |
const Vtr & |
v |
) |
[friend] |
Vtr operator+ |
( |
const Vtr & |
v1, |
|
|
const Vtr & |
v2 | |
|
) |
| | [friend] |
Definition at line 65 of file yang.cc.
{
if (v1.lenth != v2.lenth ) error("Vtr::op+: Error Bad vtor sizes");
Vtr sum = v1;
sum += v2;
return sum;
}
Vtr operator- |
( |
const Vtr & |
v |
) |
[friend] |
Vtr operator- |
( |
const Vtr & |
v1, |
|
|
const Vtr & |
v2 | |
|
) |
| | [friend] |
Definition at line 72 of file yang.cc.
{
Vtr sum = v1;
sum -= v2;
return sum;
}
Vtr operator/ |
( |
const Vtr & |
v, |
|
|
const double |
scalar | |
|
) |
| | [friend] |
Definition at line 122 of file yang.cc.
{
if (scalar == 0) error("division by zero in vector-scalar division");
return (1.0/scalar)*v;
}
std::ostream& operator<< |
( |
std::ostream & |
s, |
|
|
const Vtr & |
v | |
|
) |
| | [friend] |
Definition at line 79 of file yang.cc.
{
for (int i =0; i < v.lenth; i++ ) {
s << v[i] << " ";
if (i%10 == 9) s << "\n";
}
return s;
}
Member Data Documentation
Definition at line 15 of file yang.h.
Referenced by dot(), maxnorm(), operator*(), operator+(), operator+=(), operator-(), operator-=(), operator<<(), operator=(), size(), twonorm(), and Vtr().
The documentation for this class was generated from the following files: