【问题标题】:Fast modular exponentiation in MapleMaple 中的快速模幂运算
【发布时间】:2014-12-04 01:19:39
【问题描述】:

计算整数矩阵对给定整数取模的幂的快速方法是什么?

我试过了:

> M := Matrix([[1,1],[1,0]]); M ^ (10 ^ 12) mod 73;

但这很慢,很可能 Maple 尝试先计算幂(有大量数字),然后才取模 73。我怎样才能说服它为每个乘法做模?

【问题讨论】:

    标签: maple exponentiation


    【解决方案1】:
    restart:
    
    M := Matrix([[1,1],[1,0]]):
    
    str:=time[real]():
    
    LinearAlgebra:-Modular:-MatrixPower(73, M, 10^12);
    
                                  [46  46]
                                  [      ]
                                  [46   0]
    
    time[real]()-str;
    
                                    0.040
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-29
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      • 2017-02-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多