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 3396188
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:22:41+00:00 2026-05-18T04:22:41+00:00

call from main matrix_multiplication(arrayA,arrayB,row1,col1,col2); function definition float matrix__multiplication(float **arrayA,float **arrayB,int row1,int col1,int col2) {

  • 0

call from main

matrix_multiplication(arrayA,arrayB,row1,col1,col2);

function definition

float matrix__multiplication(float **arrayA,float **arrayB,int row1,int col1,int col2)
{
float result[row1][col2];
result[][]=....

return result;
}

I wanted to know how to pass 2d arrays in function call,
how to receive in function definition
and how to return the result matrix?

  • 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-18T04:22:41+00:00Added an answer on May 18, 2026 at 4:22 am

    Using raw pointers for your arrays like this is more C style than C++. Use vector of vector (indexing is still very efficient).

    size_t rows(5);
    size_t columns(15);
    vector<float> row(columns);
    vector<vector<float>> matrix(rows, row);
    matrix[0][0] = 0.1f;
    

    Better yet wrap the underlying storage in a Matrix class that implements the required matrix operations, holds and enforces dimensions, ensures matrices are compatible for the multiplication, and so on.

    class Matrix
    { 
    public:
      Matrix(const int _rows, const int _cols) : rows(_rows), cols(_cols)
      {
      }
    
      Matrix Multiply(const Matrix& rhs);
    
    private:
      vector<vector<float>> storage;
      size_t rows;
      size_t cols;
    };
    
    Matrix Matrix::multiply(const Matrix& rhs)
    {
      Matrix result(*this, rhs);   // construct matrix of right dimensions
      // multiply the operands
      return result;     // modern compilers do not copy construct the result
    }
    

    If your matrix demands are complex you could consider a library like Boost.UBlas versus roll your own. This is templated code and supports specializations for sparse, diagonal and other common types of matrix.

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

Sidebar

Related Questions

How can I call a function in file1.as from file2.as? here is the code.
I have some C++ Win32 code that I want to call from Ruby. But
I'm trying to write a program with a function which returns a matrix with
I am writing a function to rotate a NxN matrix by 90 degree. Here
Logic error problem with the Gaussian Elimination code...This code was from my Numerical Methods
Given the following code: void foo( int* array ) { // ... } void
I have a main Table, with several child tables. TableA and TableAChild1 and TableAChild2.
I found some good resources for rotating a bitmap in android here and elsewher
I'm implementing a simple camera system in OpenGL. I set up gluPerspective under the
I know this question was answered before, but I cant still handle it with

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.