【问题标题】:linear computation on very big matrix在非常大的矩阵上进行线性计算
【发布时间】:2012-01-17 12:32:06
【问题描述】:

我们需要计算矩阵行上的所有线性组合(二进制数模2)

    [C1|C2|C3|C4|C5|C6|C7]
R1: [1 |0 | 0| 0| 0| 0|1 ]
R2: [1 |0 | 0| 0| 0| 0|1 ]
R3: [1 |0 | 0| 0| 0| 0|1 ]
R4: [1 |0 | 0| 0| 0| 0|1 ]

1) R1、R2、R3、R4

2) R1+R2、R1+R3、R1+R4、 R2+R3,R2+R4, R3+R4

3) R1+R2+R3,R1+R2+R4, R1+R3+R4

4) R1+R2+R3+R4

i) ...

我使用了二叉树,但它真的很慢,因为矩阵很大(大约 ~50000*50000)

bool Util::binomialTree(int start, int end, int depth, 
        int *tab_index, vector<YNumber*> resultatY,  int size_factor, mpz_t n){
    int i;
    // tab_index contains all the index of the 
    // matrix and depth contains the index numbers in tab_index
    // computation here
    for (i = start + 1; i < end; i++){
            if (binomialTree (i, end, depth + 1,tab_index,
                        resultatY, size_factor, n)){
                return true;
            }
     }
    return false;
}

你能推荐一个有效的算法吗?

【问题讨论】:

  • 您是在寻找二进制矩阵中行的线性组合数(即 2^NumberOfRows)还是所有线性组合的列表(可以像通过非常大的 NumberOfRows 位数并打印出哪些数字设置为 1)?

标签: c++ algorithm matrix


【解决方案1】:

我正在考虑一个前缀树,其中字符是矩阵中的坐标。当您添加到树中时,将以下坐标的值添加到父节点的值中。这样,您只需为 (R1+R2+R3+R4) 和 (R1+R2+R3+R4+R5) 计算 (R1+R2+R3) 一次。

我希望这是可以理解的......

想解释一下为什么选择二叉树吗?

【讨论】:

    猜你喜欢
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 2015-04-12
    • 2015-01-10
    • 2019-02-24
    • 1970-01-01
    • 2015-11-18
    • 2012-06-14
    相关资源
    最近更新 更多