Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 81903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:31:59+00:00 2026-05-10T21:31:59+00:00

I think this must be simple but I can’t get it right… I have

  • 0

I think this must be simple but I can’t get it right…

I have an MxM triangular matrix, the coefficients of which are stored in a vector, row by row. For example:

M =   [ m00 m01 m02 m03 ]        [     m11 m12 m13 ]       [         m22 m23 ]       [             m33 ] 

is stored as

coef[ m00 m01 m02 m03 m11 m12 m13 m22 m23 m33 ] 

Now I’m looking for a non-recursive algorithm that gives me for matrix size M and coefficient array index i

unsigned int row_index(i,M) 

and

unsigned int column_index(i,M) 

of the matrix element that it refers to. So, row_index(9,4) == 3, column_index(7,4) == 2 etc. if the index counting is zero-based.

EDIT: Several replies using an iteration have been given. Does anyone know of algebraic expressions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:32:00+00:00Added an answer on May 10, 2026 at 9:32 pm

    Here’s an algebraic (mostly) solution:

    unsigned int row_index( unsigned int i, unsigned int M ){     double m = M;     double row = (-2*m - 1 + sqrt( (4*m*(m+1) - 8*(double)i - 7) )) / -2;     if( row == (double)(int) row ) row -= 1;     return (unsigned int) row; }   unsigned int column_index( unsigned int i, unsigned int M ){     unsigned int row = row_index( i, M);     return  i - M * row + row*(row+1) / 2; } 

    EDIT: fixed row_index()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this is a simple question, but I can not find the answer
I think this is going to be one of those simple-when-you-see-it problems, but it
I'm sure this is a simple issue, but I have noticed that when I
I feel like this is a very noob question.. but I just can't get
Sorry if this is a simple question, but I just can't figure out what
I must admin this is kind of funny even though I think I understand
I think this is likely to be a generic .NET assembly loading question, but
i think this is a bit of a noob question, but here goes. I
Make things as simple as possible, but no simpler. Can we find the solution/s
I know I must be making a simple syntax mistake, but I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.