本文整理汇总了C++中vec_RR类的典型用法代码示例。如果您正苦于以下问题:C++ vec_RR类的具体用法?C++ vec_RR怎么用?C++ vec_RR使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vec_RR类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: negate
void negate(vec_RR& x, const vec_RR& a)
{
long n = a.length();
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
negate(x[i], a[i]);
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:8,代码来源:vec_RR.c
示例2: mul
void mul(vec_RR& x, const vec_RR& a, const RR& b_in)
{
RR b = b_in;
long n = a.length();
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
mul(x[i], a[i], b);
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:9,代码来源:vec_RR.c
示例3: sub
void sub(vec_RR& x, const vec_RR& a, const vec_RR& b)
{
long n = a.length();
if (b.length() != n) Error("vector sub: dimension mismatch");
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
sub(x[i], a[i], b[i]);
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:9,代码来源:vec_RR.c
示例4: add
void add(vec_RR& x, const vec_RR& a, const vec_RR& b)
{
long n = a.length();
if (b.length() != n) LogicError("vector add: dimension mismatch");
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
add(x[i], a[i], b[i]);
}
开发者ID:axelexic,项目名称:NTL,代码行数:10,代码来源:vec_RR.c
示例5: computeAverageRR
RR computeAverageRR (vec_RR &result){
RR average = 0;
for (int i = 1; i <= result.length() ; i++){
average += result(i);
}
return average/result.length();
}
开发者ID:FredericJacobs,项目名称:Lattices-Jacobi_Method,代码行数:10,代码来源:JacobiTests.cpp
示例6: InnerProduct
void InnerProduct(RR& xx, const vec_RR& a, const vec_RR& b)
{
RR t1, x;
long n = min(a.length(), b.length());
long i;
clear(x);
for (i = 1; i <= n; i++) {
mul(t1, a(i), b(i));
add(x, x, t1);
}
xx = x;
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:15,代码来源:vec_RR.c
示例7: clear
void clear(vec_RR& x)
{
long n = x.length();
long i;
for (i = 0; i < n; i++)
clear(x[i]);
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:7,代码来源:vec_RR.c
示例8: VectorCopy
void VectorCopy(vec_RR& x, const vec_RR& a, long n)
{
if (n < 0) Error("VectorCopy: negative length");
if (NTL_OVERFLOW(n, 1, 0)) Error("overflow in VectorCopy");
long m = min(n, a.length());
x.SetLength(n);
long i;
for (i = 0; i < m; i++)
x[i] = a[i];
for (i = m; i < n; i++)
clear(x[i]);
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:17,代码来源:vec_RR.c
示例9: IsZero
long IsZero(const vec_RR& a)
{
long n = a.length();
long i;
for (i = 0; i < n; i++)
if (!IsZero(a[i]))
return 0;
return 1;
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:11,代码来源:vec_RR.c
示例10: mul_aux
static
void mul_aux(vec_RR& x, const mat_RR& A, const vec_RR& b)
{
long n = A.NumRows();
long l = A.NumCols();
if (l != b.length())
Error("matrix mul: dimension mismatch");
x.SetLength(n);
long i, k;
RR acc, tmp;
for (i = 1; i <= n; i++) {
clear(acc);
for (k = 1; k <= l; k++) {
mul(tmp, A(i,k), b(k));
add(acc, acc, tmp);
}
x(i) = acc;
}
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:23,代码来源:mat_RR.cpp
示例11: solve
void solve(RR& d, vec_RR& X,
const mat_RR& A, const vec_RR& b)
{
long n = A.NumRows();
if (A.NumCols() != n)
Error("solve: nonsquare matrix");
if (b.length() != n)
Error("solve: dimension mismatch");
if (n == 0) {
set(d);
X.SetLength(0);
return;
}
long i, j, k, pos;
RR t1, t2;
RR *x, *y;
mat_RR M;
M.SetDims(n, n+1);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++)
M[i][j] = A[j][i];
M[i][n] = b[i];
}
RR det;
set(det);
RR maxval;
for (k = 0; k < n; k++) {
pos = -1;
clear(maxval);
for (i = k; i < n; i++) {
abs(t1, M[i][k]);
if (t1 > maxval) {
pos = i;
maxval = t1;
}
}
if (pos != -1) {
if (k != pos) {
swap(M[pos], M[k]);
negate(det, det);
}
mul(det, det, M[k][k]);
// make M[k, k] == -1
inv(t1, M[k][k]);
negate(t1, t1);
for (j = k+1; j <= n; j++) {
mul(M[k][j], M[k][j], t1);
}
for (i = k+1; i < n; i++) {
// M[i] = M[i] + M[k]*M[i,k]
t1 = M[i][k];
x = M[i].elts() + (k+1);
y = M[k].elts() + (k+1);
for (j = k+1; j <= n; j++, x++, y++) {
// *x = *x + (*y)*t1
mul(t2, *y, t1);
add(*x, *x, t2);
}
}
}
else {
clear(d);
return;
}
}
X.SetLength(n);
for (i = n-1; i >= 0; i--) {
clear(t1);
for (j = i+1; j < n; j++) {
mul(t2, X[j], M[i][j]);
add(t1, t1, t2);
}
sub(t1, t1, M[i][n]);
X[i] = t1;
}
d = det;
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:97,代码来源:mat_RR.cpp
注:本文中的vec_RR类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论