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

  • Home
  • SEARCH
  • 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 191055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:18:31+00:00 2026-05-11T16:18:31+00:00

I need to implement operations with matrices and size of matrix has to be

  • 0

I need to implement operations with matrices and size of matrix has to be variable. The only solution I came up with is to use linked list:

[pointer to this row, pointer to another row] -> [element 1,1; link to another element] -> [element 1,2,  link to another element] -> .... -> [nil]
     |
     v
[pointer to this row, pointer to another row] ...
     ...

But it seems to me a little bit complex.. Is there a better (and easier) solution?

Thank you guys!

  • 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. Editorial Team
    Editorial Team
    2026-05-11T16:18:31+00:00Added an answer on May 11, 2026 at 4:18 pm

    One approach would be to use GetMem to allocate exactly enough memory. GetMem seems widely supported.

    const
        MAXMATRIXDATA: Word = 10000;
    type
        TMatrixDataType = Word;
        TMatrixData = array[0..MAXMATRIXDATA] of TMatrixDataType;
        PMatrixData = ^TMatrixData;
        TMatrix = record
            Rows, Cols: Word;
            MatrixData: PMatrixData;
            end;
        PMatrix = ^TMatrix;
    
    function CreateMatrix(Rows, Cols: Word): PMatrix;
    var
        Ret: PMatrix;
    begin
        New(Ret);
        Ret^.Rows := Rows;
        Ret^.Cols := Cols;
        GetMem(Ret^.MatrixData,Rows*Cols*SizeOf(TMatrixDataType));
        CreateMatrix := Ret;
    end;
    
    function GetMatrixData(Matrix: PMatrix; Row, Col: Word): TMatrixDataType;
    begin
        GetMatrixData := Matrix^.MatrixData^[(Row*Matrix^.Cols)+Col];
    end;
    
    procedure SetMatrixData(Matrix: PMatrix; Row, Col: Word; Val: TMatrixDataType);
    begin
        Matrix^.MatrixData^[(Row*Matrix^.Cols)+Col] := Val;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the sort algorithm with fewest number of operations? I need to implement
I use SQL Server 2008. I need to DENY any delete operations on a
I need to implement a class which will be used for same image operations.
I'm aware, that I need to use mutex, when I perform operations on single
I need to implement a Linux Kernel Driver, that (in the first step) only
How should I implement a linked list in PHP? Is there a implementation built
I need to implement a custom handler for MVC that gives me the first
I need to implement login velocity checking for a web service. The service is
I need to implement Integrated Windows Authentication for a WCF service hosted on IIS
I need to implement a SOAP Web Service on Jboss Seam 2.1.0. The idea

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.