简体   繁体   English

Java中的多线程矩阵初始化

[英]Multi-threaded Matrix initializing in Java

Currently using JAMA matrix. 当前使用的是JAMA矩阵。

my program currently initializes a LOT of small matrixs (20x20 tops in size) and then does some small calculations and reads the results. 我的程序当前初始化许多小矩阵(大小为20x20的顶部),然后进行一些小计算并读取结果。

about 80% of the run time is being spent reading and initializing the matrixs and I was wondering if there is a way I can do this multi-threaded for increased speeds. 大约80%的运行时间都花在了读取和初始化矩阵上,我想知道是否有一种方法可以通过多线程来提高速度。 (I know that there are things like OjAlgo that are great for multi-thraded matrix manipulation) but all I am doing is initializing the matrix's and reading them again. (我知道像OjAlgo这样的东西非常适合多阈值矩阵操作),但是我要做的只是初始化矩阵并再次读取它们。

If I use another Matrix package will it initialize the matrixs with multiple threads or would the initialization still be single threaded but the algorthems done be multi-threaded? 如果我使用另一个Matrix包,它将使用多个线程来初始化矩阵,还是将初始化仍然是单线程的,但是完成的算法是多线程的?

Multi-threading "within" the matrices wont be of any benefit for such small matrices. 矩阵“内部”的多线程对于这种小型矩阵不会有任何好处。

Switching to a library that internally uses double[] rather than double[][] could make a difference, but my guess is you should focus on how you (re)use the matrices. 切换到内部使用double []而不是double [] []的库可能会有所不同,但是我的猜测是您应该专注于如何(重新)使用矩阵。 Maybe your program logic can be multi-threaded. 也许您的程序逻辑可以是多线程的。

For very small matrices (2x2, 3x3, 4x4 ...) some libraries have specialised data structures and algorithms that could speed things up significantly. 对于很小的矩阵(2x2、3x3、4x4 ...),某些库具有专门的数据结构和算法,可以大大加快处理速度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM