从下三角矩阵给出一个元素(Giving an element from lower/upper triangular matrix)

编程入门 行业动态 更新时间:2024-10-27 10:29:23
从下三角矩阵给出一个元素(Giving an element from lower/upper triangular matrix)

我有一个矩阵的上三角部分,主对角线存储为线性阵列,矩阵元素的(i,j)指数如何从阵列的线性索引中提取?

例如,对于矩阵存储线性阵列: [a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]

a0 a1 a2 a3 0 a4 a5 a6 0 0 a7 a8 0 0 0 a10

我找到了这个问题的解决方案,但没有主对角线,它是:

index = (n*(n-1)/2) - (n-i)*((n-i)-1)/2 + j - i - 1

并解决相同的问题,但对于具有对角线的下三角矩阵:

index = ((i + 1) * i / 2 + i).

问候,

I have the upper triangular portion of a matrix, with the main diagonal stored as a linear array, how can the (i,j) indices of a matrix element be extracted from the linear index of the array?

For example the linear array :[a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]is storage for the matrix

a0 a1 a2 a3 0 a4 a5 a6 0 0 a7 a8 0 0 0 a10

I've found solutions for this problem but without the main diagonal which is:

index = (n*(n-1)/2) - (n-i)*((n-i)-1)/2 + j - i - 1

And solution for the same problem but for a lower triangular matrix with the diagonal:

index = ((i + 1) * i / 2 + i).

Regards,

更多推荐

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

发布评论

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

>www.elefans.com

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