展开一个密集的矩阵

编程入门 行业动态 更新时间:2024-10-28 15:27:44
本文介绍了展开一个密集的矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在FORTRAN中用新列扩展密集矩阵的最有效方法是什么?

说T是一个密集的矩阵m乘n ,我想用n + 1。 我能想到的一个策略:在每一步重新分配并分配最后一列,或者是否会有一些更好的方法,比如先分配一些空间并检查是否足够,如果不是这样的重新分配类型的东西?任何想法?

解决方案

假设 m 和在某些意义上,n 不会太大,这样你的矩阵就可以适应内存,而你所追求的是时间表现,我会做什么我会分配一个大的矩阵并存储实际的大小分开。例如,这就是BLAS库用作主要维度的原因。然后,当您需要添加列时,请检查您的实际大小是否仍小于最大大小,并在必要时重新分配内存。

What would be the most efficient way to expand a dense matrix with new columns in FORTRAN?

Say T is a dense matrix m by n

and I would like to make it m by n+1. One strategy I could think of : Reallocate at each step and assign the last column or would there be some better ways, such as allocating some space before and checking if that is sufficient and if not do the reallocation kind of stuff? Any ideas?

解决方案

Assuming m and n are in some sense not exceedingly large, so that your matrices fit into memory and what you're after is performance in time, what I'd do I'd allocate a large matrix and store the actual size separately. This is what, for example, BLAS libraries use as a 'leading dimension'. Then, when you need to add a column, you check if your actual size is still smaller than the maximum size, and reallocate memory if necessary.

更多推荐

展开一个密集的矩阵

本文发布于:2023-11-26 12:20:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633912.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:矩阵   密集

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!