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

Enabled editing of matricies after construction #10

Closed
wants to merge 1 commit into from
Closed

Enabled editing of matricies after construction #10

wants to merge 1 commit into from

Conversation

YetAnotherMinion
Copy link
Contributor

previously one could not edit the contents of an apf::Matrix after it had been constructed.
this was annoying when trying to allocate an array of apf::Matrix and having the default constructor called for every matrix. Now you can actually use the matrix in the array.

@bgranzow
Copy link
Contributor

I think it's fine to add that type of access operator, but I'm not going to make the final call to merge the pull request. Your claim about not being able to edit entries of a matrix after construction isn't true, though. The code below shows how you can do that.

#include "apfMatrix.h"

int main()
{
  apf::Matrix<2,2> A;
  A[0][0] = 1.0; A[0][1] = 0.0;
  A[1][0] = 0.0; A[1][1] = 1.0;
  std::cout << A;
}

@YetAnotherMinion
Copy link
Contributor Author

I had tried that at the beginning, and got a segfault, which was what prompted trying to add the operators. Looking back right now, I got the segfault because I did this

apf::NewArray< apf::Matrix< 3,2 > > B;
/*construct each of the nnodes shape function matricies*/
uint32_t ii;
for(ii = 0; ii < this->nnodes; ++ii) {
    B[ii][0][0] = gradShape[ii][0];

I had forgotten to allocate the array! Which I only discovered after I had made the changes and tested the new methods.

I withdraw the pull request since it is not needed.

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

Successfully merging this pull request may close these issues.

None yet

2 participants