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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:13:59+00:00 2026-06-09T20:13:59+00:00

I have two matrices: A and B. How can I store them? How can

  • 0

I have two matrices: A and B.

  1. How can I store them?
  2. How can I calculate the inverse matrix of matrix A using the Accelerate framework?
  3. How can find the product of A*B?
  4. How can I transpose matrix A using the Accelerate framework?

Thank you for answering my questions!

Helper file

#import <Foundation/Foundation.h>
#include <Accelerate/Accelerate.h>

@interface Working_with_matrices : NSObject
-(int)invert_matrix:(int) N andWithMatrix:(double*) matrix;
@end

Implementation file

#import "Working_with_matrices.h"
#include <Accelerate/Accelerate.h>

@implementation Working_with_matrices
-(int) matrix_invert:(int) N andWithMatrix:(double*)matrix
{    
int error=0;
int *pivot = malloc(N*N*sizeof(int));
double *workspace = malloc(N*sizeof(double));

dgetrf_(&N, &N, matrix, &N, pivot, &error);

if (error != 0) {
    NSLog(@"Error 1");
    return error;
}

dgetri_(&N, matrix, &N, pivot, workspace, &N, &error);

if (error != 0) {
    NSLog(@"Error 2");
    return error;
}

free(pivot);
free(workspace);
return error;
}

Call my code from main function

#import <Foundation/Foundation.h>
#import "Working_with_matrices.h"

int main(int argc, const char * argv[])
{
int N = 3;
double A[9];
Working_with_matrices* wm=[[Working_with_matrices alloc]init];

A[0] = 1; A[1] = 1; A[2] = 7;
A[3] = 1; A[4] = 2; A[5] = 1;
A[6] = 1; A[7] = 1; A[8] = 3;
[wm invert_matrix:N andWithMatrix:A];
//        [ -1.25  -1.0   3.25 ]
// A^-1 = [  0.5    1.0  -1.5  ]
//        [  0.25   0.0  -0.25 ] 
for (int i=0; i<9; i++) 
{
    NSLog(@"%f", A[i]);
}
return 0;
}
  • 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-06-09T20:14:01+00:00Added an answer on June 9, 2026 at 8:14 pm

    I’m still kinda new to using the accelerate framework but I’ll answer what I can.

    1. The accelerate framework expects the matrices to be passed in as a
      1D array. So if you have a 4×4 matrix, the first row would be placed
      in indexes 0-3 of your array, the second rouw would be placed in
      indexes 4-7 and so on.
    2. I’ve never done it but this answer looks like a good starting point. https://stackoverflow.com/a/11321499/385017
    3. The method you’ll want to use is vDSP_mmul for single precision or vDSP_mmulD for double precision. You might want to look at the documentation for it to get a better unerstanding of how to use it but heres an example to get you started.

      float *matrixA;  //set by you
      float *matrixB;  //set by you
      float *matrixAB; //the matrix that the answer will be stored in
      
      vDSP_mmul( matrixA, 1, matrixB, 1, matrixAB, 1, 4, 4, 4 );
      // the 1s should be left alone in most situations
      // The 4s in order are:
      //     the number of rows in matrix A
      //     the number of columns in matrix B
      //     the number of columns in matrix A and the number of rows in matrix B.
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have two numpy matrices, how can you join them together into one?
I have two matrices of different sizes. Let's just define matrix {a} as a(1:10)
In short: I have two matrices (or arrays): import numpy block_1 = numpy.matrix([[ 0,
I'm using Python with Matplotlib for drawing. I have two matrices (images in levels
I have two matrices A and B. Each of them has 2 columns having
I have two 4x4 OPENGL Matrices - 1st matrix holds rotation and position of
I have two matrices like the following ones: '01/01/2010' 1 '02/01/2010' 2 '03/01/2010' 3
I have two matrices. The first contains values, and the second contains names corresponding
I have two matrices a and b (with equal number of columns). I want
I have two matrices A and B , both of which are Nx3 matrices.

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.