Click here to Skip to main content
15,894,017 members
Articles / General Programming / Algorithms

From Linear to Upper Triangular Matrix Indices

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
20 Sep 2023Public Domain3 min read 6.1K   65   2  
A couple of lines of code to get the i-j indices of an upper triangular matrix (main diagonal included) from a linerized array.
You may have data that is conceptually set in an upper triangular matrix, but is actually stored in a 1d array. There comes a moment when you need to get the row/column indices of the entries. This tip has the formulas to derive them.

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Instructor / Trainer
Italy Italy
I teach operational analytics in addition to basic algorithms. I have expertise in heuristic optimization and data series forecasting.

Comments and Discussions