Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscripted View for Fixed-Sized Matrices and Vectors #105

Open
ProfFan opened this issue Jun 26, 2020 · 1 comment
Open

Subscripted View for Fixed-Sized Matrices and Vectors #105

ProfFan opened this issue Jun 26, 2020 · 1 comment
Assignees

Comments

@ProfFan
Copy link
Collaborator

ProfFan commented Jun 26, 2020

When implementing the chordal initialization I found out that it is almost essential that we have:

  1. a mutable, subscripted view into the fixed-size matrices;
  2. methods like MatrixN.zero and MatrixN.identity.

Otherwise I end up writing code like this:

let M9: Jacobian9x9_2 = Array9([
        Tuple2(Vector9(-1,0,0,0,0,0,0,0,0), Vector9(Rij.s00,Rij.s01,Rij.s02,0,0,0,0,0,0)),
        Tuple2(Vector9(0,-1,0,0,0,0,0,0,0), Vector9(Rij.s10,Rij.s11,Rij.s12,0,0,0,0,0,0)),
        Tuple2(Vector9(0,0,-1,0,0,0,0,0,0), Vector9(Rij.s20,Rij.s21,Rij.s22,0,0,0,0,0,0)),
        Tuple2(Vector9(0,0,0,-1,0,0,0,0,0), Vector9(0,0,0,Rij.s00,Rij.s01,Rij.s02,0,0,0)),
        Tuple2(Vector9(0,0,0,0,-1,0,0,0,0), Vector9(0,0,0,Rij.s10,Rij.s11,Rij.s12,0,0,0)),
        Tuple2(Vector9(0,0,0,0,0,-1,0,0,0), Vector9(0,0,0,Rij.s20,Rij.s21,Rij.s22,0,0,0)),
        Tuple2(Vector9(0,0,0,0,0,0,-1,0,0), Vector9(0,0,0,0,0,0,Rij.s00,Rij.s01,Rij.s02)),
        Tuple2(Vector9(0,0,0,0,0,0,0,-1,0), Vector9(0,0,0,0,0,0,Rij.s10,Rij.s11,Rij.s12)),
        Tuple2(Vector9(0,0,0,0,0,0,0,0,-1), Vector9(0,0,0,0,0,0,Rij.s20,Rij.s21,Rij.s22))
      ])

Moreover, it becomes almost impossible to write code when I try to implement SVD for 3x3 rotation matrices as I cannot write stuff like A[0, 0], and I cannot dynamically index the matrix in for loops...

I am not sure if this design is good in a "Swifty" sense, so please correct me if I make silly mistakes!

@marcrasi
Copy link
Collaborator

These operations sound good to me!

We've talked a lot about the ideal fixed size matrix and I think we still haven't figured it out yet, but that shouldn't stop us from having a quick and dirty implementation that supports all the operations you need. I think I could have one ready in a few hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants