python 多线程并行 矩阵乘法_Python多线程矩阵乘法

我正在做一个学期末的专题,我需要能够把一个矩阵的幂次,我需要使问题多线程。在

此代码在某些情况下有效,而在其他情况下则不行。我相信这与process_data函数中嵌套循环的逻辑有关,但我不确定我做错了什么!我已经为这个工作了几个星期了,我完全被难住了。这似乎与我的线程越界有关,但即使如此,我也不太确定,因为有些情况下线程超出了界限,但仍然正确地计算矩阵。在

请帮忙!在import copy

import numpy

import Queue

import random

import threading

import time

import timeit

# Create variable that determines the number of columns and

# rows in the matrix.

n = 4

# Create variable that determines the power we are taking the

# matrix to.

p = 2

# Create variable that determines the number of threads we are

# using.

t = 2

# Create an exit flag.

exitFlag = 0

# Create threading class.

class myThread (threading.Thread):

def __init__(self, threadID, name, q):

t

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值