#include <yang.h>
Private Attributes |
int | lenth |
double * | ets |
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.
{
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.
{
for (
int i = 0; i <
lenth; i++)
ets[i] = a;
}
Vtr::Vtr |
( |
const Vtr & |
v | ) |
|
Definition at line 28 of file yang.cc.
{
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 | ) |
|
Definition at line 45 of file yang.cc.
{
for (
int i = 0; i <
lenth; i++)
ets[i] += v[i];
return *this;
}
Vtr & Vtr::operator-= |
( |
const Vtr & |
v | ) |
|
Definition at line 51 of file yang.cc.
{
for (
int i = 0; i <
lenth; i++)
ets[i] -= v[i];
return *this;
}
Vtr & Vtr::operator= |
( |
const Vtr & |
v | ) |
|
Definition at line 37 of file yang.cc.
{
if (this != &v) {
for (
int i = 0; i <
lenth; i++)
ets[i] = v[i];
}
return *this;
}
double& Vtr::operator[] |
( |
int |
i | ) |
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.
{
double tm = v1[0]*v2[0];
for (int i = 1; i < sz; i++) tm += v1[i]*v2[i];
return tm;
}
Vtr operator* |
( |
const double |
scalar, |
|
|
const Vtr & |
v |
|
) |
| |
|
friend |
Definition at line 107 of file yang.cc.
{
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 & |
v1, |
|
|
const Vtr & |
v2 |
|
) |
| |
|
friend |
Definition at line 113 of file yang.cc.
{
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.
{
error(
"op*(Vtr, Mtx): Error: Mat. and vec. size do no match.");
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 Vtr & |
v | ) |
|
|
friend |
Vtr operator+ |
( |
const Vtr & |
v1, |
|
|
const Vtr & |
v2 |
|
) |
| |
|
friend |
Definition at line 65 of file yang.cc.
{
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.
{
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: