• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ mat_ZZ类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中mat_ZZ的典型用法代码示例。如果您正苦于以下问题:C++ mat_ZZ类的具体用法?C++ mat_ZZ怎么用?C++ mat_ZZ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了mat_ZZ类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: transpose

void transpose(mat_ZZ& X, const mat_ZZ& A)
{
    long n = A.NumRows();
    long m = A.NumCols();

    long i, j;

    if (&X == & A) {
        if (n == m)
            for (i = 1; i <= n; i++)
                for (j = i+1; j <= n; j++)
                    swap(X(i, j), X(j, i));
        else {
            mat_ZZ tmp;
            tmp.SetDims(m, n);
            for (i = 1; i <= n; i++)
                for (j = 1; j <= m; j++)
                    tmp(j, i) = A(i, j);
            X.kill();
            X = tmp;
        }
    }
    else {
        X.SetDims(m, n);
        for (i = 1; i <= n; i++)
            for (j = 1; j <= m; j++)
                X(j, i) = A(i, j);
    }
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:29,代码来源:mat_ZZ.c


示例2: image

static
long image(ZZ& det, mat_ZZ& B, mat_ZZ* U, long verbose)
{
   long m = B.NumRows();
   long n = B.NumCols();

   long force_reduce = 1;

   vec_long P;
   P.SetLength(m);

   vec_ZZ D;
   D.SetLength(m+1);
   D[0] = 1;

   vec_vec_ZZ lam;

   lam.SetLength(m);

   long j;
   for (j = 1; j <= m; j++)
      lam(j).SetLength(m);

   if (U) ident(*U, m);

   long s = 0;

   long k = 1;
   long max_k = 0;


   while (k <= m) {
      if (k > max_k) {
         IncrementalGS(B, P, D, lam, s, k);
         max_k = k;
      }

      if (k == 1) {
         force_reduce = 1;
         k++;
         continue;
      }

      if (force_reduce)
         for (j = k-1; j >= 1; j--)
            reduce(k, j, B, P, D, lam, U);

      if (P(k-1) != 0 && P(k) == 0) {
         force_reduce = swap(k, B, P, D, lam, U, max_k, verbose);
         k--;
      }
      else {
         force_reduce = 1;
         k++;
      }
   }

   det = D[s];
   return s;
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:60,代码来源:LLL.c


示例3: mul_aux

void mul_aux(mat_ZZ& X, const mat_ZZ& A, const mat_ZZ& B)
{
    long n = A.NumRows();
    long l = A.NumCols();
    long m = B.NumCols();

    if (l != B.NumRows())
        Error("matrix mul: dimension mismatch");

    X.SetDims(n, m);

    long i, j, k;
    ZZ acc, tmp;

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= m; j++) {
            clear(acc);
            for(k = 1; k <= l; k++) {
                mul(tmp, A(i,k), B(k,j));
                add(acc, acc, tmp);
            }
            X(i,j) = acc;
        }
    }
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:25,代码来源:mat_ZZ.c


示例4: GS_reduce

vec_ZZ  GS_reduce(mat_ZZ mat, vec_ZZ vec, ZZ weight)
{
    vec_ZZ          target;
    ZZ_mat<mpz_t>   mat_fp;
    mat_ZZ          mat_exp;
    int             row, col;


    row     =   mat.NumRows();
    col     =   mat.NumCols();
    mat_exp.SetDims(row+1, col+1);

    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
        {
            mat_exp[i][j] =   mat[i][j];
        }
    }
    for(int i=0;i<col;i++)
    {
        mat_exp[row][i] =   vec[i];
    }
    mat_exp[row][col]   =   weight;

    mat_fp  =   convert<ZZ_mat<mpz_t> ,mat_ZZ >(mat_exp);
    lllReduction(mat_fp, 0.99,0.51, LM_WRAPPER,FT_DEFAULT, 0, LLL_DEFAULT);
    mat_exp =   convert<mat_ZZ ,ZZ_mat<mpz_t> >(mat_fp);
    target.SetLength(col);
    for (int i=0;i<col;i++)
        target[i]   =   mat_exp[row][i];
//    cout<<target<<endl;
    return target;
}
开发者ID:zhenfeizhang,项目名称:hybrid_GH,代码行数:34,代码来源:tools.cpp


示例5: power

void power(mat_ZZ& X, const mat_ZZ& A, const ZZ& e)
{
    if (A.NumRows() != A.NumCols()) Error("power: non-square matrix");

    if (e == 0) {
        ident(X, A.NumRows());
        return;
    }

    mat_ZZ T1, T2;
    long i, k;

    k = NumBits(e);
    T1 = A;

    for (i = k-2; i >= 0; i--) {
        sqr(T2, T1);
        if (bit(e, i))
            mul(T1, T2, A);
        else
            T1 = T2;
    }

    if (e < 0)
        inv(X, T1);
    else
        X = T1;
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:28,代码来源:mat_ZZ.c


示例6: conv

void conv(mat_ZZ_p& x, const mat_ZZ& a)
{
    long n = a.NumRows();
    long m = a.NumCols();
    long i;

    x.SetDims(n, m);
    for (i = 0; i < n; i++)
        conv(x[i], a[i]);
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:10,代码来源:mat_ZZ.c


示例7: MaxBits

static
long MaxBits(const mat_ZZ& A)
{
    long m = 0;
    long i, j;
    for (i = 0; i < A.NumRows(); i++)
        for (j = 0; j < A.NumCols(); j++)
            m = max(m, NumBits(A[i][j]));

    return m;
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:11,代码来源:mat_ZZ.c


示例8: sqrt

RR ReductionQualityChecker::computeOrthogonalityDefect(mat_ZZ &mat) {
    

    RR multResult = sqrt(normsq(mat(1)));

    for (int i = 2; i <= mat.NumRows(); i++) {
        multResult *= sqrt(normsq(mat(i)));
    }
        mat_ZZ B = mat * transpose(mat);
    RR denominator = sqrt(determinant(B));
       return pow(multResult/denominator, 1./mat.NumRows());
}
开发者ID:FredericJacobs,项目名称:Lattices-Jacobi_Method,代码行数:12,代码来源:ReductionQualityChecker.cpp


示例9: mul

void mul(mat_ZZ& X, const mat_ZZ& A, long b)
{
    long n = A.NumRows();
    long m = A.NumCols();

    X.SetDims(n, m);

    long i, j;
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            mul(X[i][j], A[i][j], b);
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:12,代码来源:mat_ZZ.c


示例10: ExactDiv

static
void ExactDiv(mat_ZZ& x, const ZZ& d)
{
    long n = x.NumRows();
    long m = x.NumCols();

    long i, j;

    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            if (!divide(x[i][j], x[i][j], d))
                Error("inexact division");
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:13,代码来源:mat_ZZ.c


示例11: negate

void negate(mat_ZZ& X, const mat_ZZ& A)
{
    long n = A.NumRows();
    long m = A.NumCols();


    X.SetDims(n, m);

    long i, j;
    for (i = 1; i <= n; i++)
        for (j = 1; j <= m; j++)
            negate(X(i,j), A(i,j));
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:13,代码来源:mat_ZZ.c


示例12: sub

void sub(mat_ZZ& X, const mat_ZZ& A, const mat_ZZ& B)
{
    long n = A.NumRows();
    long m = A.NumCols();

    if (B.NumRows() != n || B.NumCols() != m)
        Error("matrix sub: dimension mismatch");

    X.SetDims(n, m);

    long i, j;
    for (i = 1; i <= n; i++)
        for (j = 1; j <= m; j++)
            sub(X(i,j), A(i,j), B(i,j));
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:15,代码来源:mat_ZZ.c


示例13: clear

void clear(mat_ZZ& x)
{
    long n = x.NumRows();
    long i;
    for (i = 0; i < n; i++)
        clear(x[i]);
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:7,代码来源:mat_ZZ.c


示例14: CharPolyBound

NTL_START_IMPL

static
long CharPolyBound(const mat_ZZ& a)
// This bound is computed via interpolation
// through complex roots of unity.

{
   long n = a.NumRows();
   long i;
   ZZ res, t1, t2;

   set(res);

   for (i = 0; i < n; i++) {
      InnerProduct(t1, a[i], a[i]);
      abs(t2, a[i][i]);
      mul(t2, t2, 2);
      add(t2, t2, 1);
      add(t1, t1, t2);
      if (t1 > 1) {
         SqrRoot(t1, t1);
         add(t1, t1, 1);
      }
      mul(res, res, t1);
   }

   return NumBits(res);
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:29,代码来源:mat_poly_ZZ.cpp


示例15: IncrementalGS

static
void IncrementalGS(mat_ZZ& B, vec_long& P, vec_ZZ& D, vec_vec_ZZ& lam,
                   long& s, long k)
{
   long n = B.NumCols();
   long m = B.NumRows();

   static ZZ u, t1, t2;

   long i, j;

   for (j = 1; j <= k-1; j++) {
      long posj = P(j);
      if (posj == 0) continue;

      InnerProduct(u, B(k), B(j));
      for (i = 1; i <= posj-1; i++) {
         mul(t1, D[i], u);
         mul(t2, lam(k)(i), lam(j)(i));
         sub(t1, t1, t2);
         div(t1, t1, D[i-1]);
         u = t1;
      }

      lam(k)(posj) = u;
   }

   InnerProduct(u, B(k), B(k));
   for (i = 1; i <= s; i++) {
      mul(t1, D[i], u);
      mul(t2, lam(k)(i), lam(k)(i));
      sub(t1, t1, t2);
      div(t1, t1, D[i-1]);
      u = t1;
   }

   if (u == 0) {
      P(k) = 0;
   }
   else {
      s++;
      P(k) = s;
      D[s] = u;
   }
}
开发者ID:Macaulay2,项目名称:Singular,代码行数:45,代码来源:LLL.c


示例16: IsIdent

long IsIdent(const mat_ZZ& A, long n)
{
    if (A.NumRows() != n || A.NumCols() != n)
        return 0;

    long i, j;

    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            if (i != j) {
                if (!IsZero(A(i, j))) return 0;
            }
            else {
                if (!IsOne(A(i, j))) return 0;
            }

    return 1;
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:18,代码来源:mat_ZZ.c


示例17: add

NTL_START_IMPL


void add(mat_ZZ& X, const mat_ZZ& A, const mat_ZZ& B)  
{  
   long n = A.NumRows();  
   long m = A.NumCols();  
  
   if (B.NumRows() != n || B.NumCols() != m)   
      LogicError("matrix add: dimension mismatch");  
  
   X.SetDims(n, m);  
  
   long i, j;  
   for (i = 1; i <= n; i++)   
      for (j = 1; j <= m; j++)  
         add(X(i,j), A(i,j), B(i,j));  
}  
开发者ID:cryptobiu,项目名称:libscapi,代码行数:18,代码来源:mat_ZZ.cpp


示例18: IsDiag

long IsDiag(const mat_ZZ& A, long n, const ZZ& d)
{
    if (A.NumRows() != n || A.NumCols() != n)
        return 0;

    long i, j;

    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            if (i != j) {
                if (!IsZero(A(i, j))) return 0;
            }
            else {
                if (A(i, j) != d) return 0;
            }

    return 1;
}
开发者ID:tvtritin,项目名称:Fuzzy-extractor,代码行数:18,代码来源:mat_ZZ.c


示例19: mul

void mul(vec_ZZ& x, const mat_ZZ& A, const vec_ZZ& b)  
{  
   if (&b == &x || A.alias(x)) {
      vec_ZZ tmp;
      mul_aux(tmp, A, b);
      x = tmp;
   }
   else
      mul_aux(x, A, b);
}  
开发者ID:cryptobiu,项目名称:libscapi,代码行数:10,代码来源:mat_ZZ.cpp


示例20: mat_expand

mat_ZZ  mat_expand(mat_ZZ M, vec_ZZ v)
{
    int     len, col, row;
    mat_ZZ  mat_exp;

    len =   v.length();
    col =   M.NumCols();
    row =   M.NumRows();

    if (len!=col)
        cout<<"Incompatible rows"<<endl;

    mat_exp =   M;
    mat_exp.SetDims(row+1, col);
    mat_exp[row] = v;



    return  mat_exp;
}
开发者ID:zhenfeizhang,项目名称:hybrid_GH,代码行数:20,代码来源:tools.cpp



注:本文中的mat_ZZ类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ mat_ZZ_p类代码示例发布时间:2022-05-31
下一篇:
C++ mat_GF2E类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap