Skip to content

Copy function #1

@davidbsp

Description

@davidbsp

Hi @tzikis and @eecharlie

I've been playing around with the MatrixMath library, and I have a very specific issue with the Copy function, which is giving me a huge headache:

Here is a minimal example:

  float X[10][40][3];    //an array of 10 matrices (40x3)
   
   //just fill it with 5's:
   for(int i=0; i<10; i++){
       for (int j=0; j<40; j++){
           for (int k=0; k<3; k++){
               X[i][j][k] = 5.0;
           }
       }
   }    

   float Q [10][40][3];    
   
  //now, I just want to copy the 1st matrix of X (located in X[0]) to Q[0]:
   Matrix.Copy( (float*)X[0], 3, 40, (float*)Q[0] );
   Serial.println("Copy done");

While the compiler doesn't complain about this code, the program segfaults after the copy operation...
Can you perhaps let me know why, and how can I solve this?

I also noticed that the Copy function receives n (cols) first and m (rows) after, as opposed to all the other functions in the library. Do you know the reason for this design choice? I would recommend to change the order for easiness of use.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions