本文整理汇总了C++中tvector::get方法的典型用法代码示例。如果您正苦于以下问题:C++ tvector::get方法的具体用法?C++ tvector::get怎么用?C++ tvector::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tvector
的用法示例。
在下文中一共展示了tvector::get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
tvector<nr_type_t> operator * (tvector<nr_type_t> a, tvector<nr_type_t> b) {
assert (a.getSize () == b.getSize ());
int n = a.getSize ();
tvector<nr_type_t> res (n);
for (int i = 0; i < n; i++) res.set (i, a.get (i) * b.get (i));
return res;
}
示例2: maxnorm
nr_double_t maxnorm (tvector<nr_type_t> a) {
nr_double_t nMax = 0, n;
for (int i = 0; i < a.getSize (); i++) {
n = norm (a.get (i));
if (n > nMax) nMax = n;
}
return nMax;
}
示例3: assert
tvector<nr_type_t> operator * (tvector<nr_type_t> a, tmatrix<nr_type_t> b) {
assert (a.getSize () == b.getRows ());
int r, c, n = b.getRows ();
nr_type_t z;
tvector<nr_type_t> res (n);
for (c = 0; c < n; c++) {
for (r = 0, z = 0; r < n; r++) z += a.get (r) * b.get (r, c);
res.set (c, z);
}
return res;
}
示例4: norm
nr_double_t norm (tvector<nr_type_t> a) {
#if 0
nr_double_t k = 0;
for (int i = 0; i < a.getSize (); i++) k += norm (a.get (i));
return n;
#else
nr_double_t scale = 0, n = 1, x, ax;
for (int i = 0; i < a.getSize (); i++) {
if ((x = real (a (i))) != 0) {
ax = fabs (x);
if (scale < ax) {
x = scale / ax;
n = 1 + n * x * x;
scale = ax;
}
else {
x = ax / scale;
n += x * x;
}
}
if ((x = imag (a (i))) != 0) {
ax = fabs (x);
if (scale < ax) {
x = scale / ax;
n = 1 + n * x * x;
scale = ax;
}
else {
x = ax / scale;
n += x * x;
}
}
}
return scale * scale * n;
#endif
}
示例5: conj
tvector<nr_type_t> conj (tvector<nr_type_t> a) {
int n = a.getSize ();
tvector<nr_type_t> res (n);
for (int i = 0; i < n; i++) res.set (i, conj (a.get (i)));
return res;
}
示例6: res
tvector<nr_type_t> operator + (nr_type_t s, tvector<nr_type_t> a) {
int n = a.getSize ();
tvector<nr_type_t> res (n);
for (int i = 0; i < n; i++) res.set (i, s + a.get (i));
return res;
}
示例7: sum
nr_type_t sum (tvector<nr_type_t> a) {
nr_type_t res = 0;
for (int i = 0; i < a.getSize (); i++) res += a.get (i);
return res;
}
示例8: scalar
nr_type_t scalar (tvector<nr_type_t> a, tvector<nr_type_t> b) {
assert (a.getSize () == b.getSize ());
nr_type_t n = 0;
for (int i = 0; i < a.getSize (); i++) n += a.get (i) * b.get (i);
return n;
}
示例9:
void tvector<nr_type_t>::set (tvector<nr_type_t> a, int start, int stop) {
for (int i = start; i < stop; i++) data[i] = a.get (i);
}