Upper Secondary Diagonals of Matrix

Upper Secondary Diagonals of Matrix - 消息

#1 已发布: 2021/12/2 12:39:56
ianlh

ianlh

0个赞,共38个帖子。

组: User

Hi,

Is there a built in function that can get the sum of the upper secondary diagonals of a matrix? some times called the skew:

skew.JPG

I can call each by its element, but I would like it to work for any a1n & an1, I can do tr(reverse) to find the secondary diagonal, after each reduction of the matrix by 1 row/column:
Diagonals.JPG
Diagonals2.JPG

matrix multiplier.sm (15.13 KiB)已下载 1225 次。

Thanks in advance
Ian


#2 已发布: 2021/12/2 15:23:54
ianlh

ianlh

0个赞,共38个帖子。

组: User

Lets say the matrix is 10 x 10, I don't want the user to have to "manually" create all the steps to get to the tr(reverse), this is a lot of work and could introduce errors. What I want is a simple (if it is indeed simple!) loop to do it.
Your solutions certainly speed up the process and wonder if they could be implemented?

Ian
#3 已发布: 2021/12/2 17:33:19
CBG

CBG

78个赞,共312个帖子。

组: User

Hello

Maybe you can do this

Matrix_M.png


Best Regards

Carlos
#4 已发布: 2021/12/2 17:42:55
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: Moderator

未找到文件。未找到文件。

(the first is more a "proof of concept", is very inefficient because it does a lot useless calculations)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#5 已发布: 2021/12/3 06:03:45
ianlh

ianlh

0个赞,共38个帖子。

组: User

Wrote

... your image red arrows represents the *.JPEG destruction.
JPG does not compress, it destroys the details bottom-right up top left.
What's the relationship between your JPG image and your attempt ?

Image jpeg.sm (53.37 KiB)已下载 1295 次。



Hi Jean,

The image was just to illustrate the direction of the summation, the primary diagonal is top left to bottom right.

Hi Carlos and Davide,

These look like interesting solutions, let me try on the larger matrix.

Thanks once again
Ian
#6 已发布: 2021/12/3 06:53:44
ianlh

ianlh

0个赞,共38个帖子。

组: User

Interesting results on the speed of calculation:
Main Matrix:
wind 1.JPG
Method Carlos:
wind 2.JPG
Method Davide:
wind 3.JPG
Comments?
#7 已发布: 2021/12/3 08:06:03
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: Moderator

Wrote

(the first is more a "proof of concept", is very inefficient because it does a lot useless calculations)



You should try the 2nd method in my file.
As stated in the previous post the first method is really inefficient, since for each iteration it calculates all the sums from the first value up to the n-th diagonal.

BTW with a random set of values and small matrices, doesn't seems so slow in my machine (WIN7PRO/AMD PRO A10/16GB RAM). With bigger matrices the difference is huge (for a 100x100 matrix, 26.1s with first method, 0.028s with second method)

2021-12-03 13_23_51-SMath Solver - [skew.sm_].png



The method to check the sum of [r,c] coordinates can be used more efficently in a double loop, though (here it is extended to the whole matrix).

2021-12-03 12_14_18-SMath Solver - [skew.sm_].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#8 已发布: 2021/12/3 11:51:14
ianlh

ianlh

0个赞,共38个帖子。

组: User

Hi,

Second method now as quick as the first by Carlos.

Jean, many opportunities for engineering!

Thanks to all

Ian
#9 已发布: 2021/12/3 21:18:32
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

Jean, many opportunities for engineering !


w/o abstract: of little interest for common visitor.

Matrix DIAGONAL.sm (11.73 KiB)已下载 1300 次。



  • 有新帖
  • 无新帖