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

missing one(::Mat) #47

Closed
stevengj opened this issue Dec 4, 2015 · 9 comments
Closed

missing one(::Mat) #47

stevengj opened this issue Dec 4, 2015 · 9 comments

Comments

@stevengj
Copy link
Contributor

stevengj commented Dec 4, 2015

Currently this works but produces a dense matrix.

@kshyatt
Copy link
Contributor

kshyatt commented Dec 4, 2015

Is the right thing to do here use MatDuplicate and then MatSetValues or is there a better/easier way?

@stevengj
Copy link
Contributor Author

stevengj commented Dec 4, 2015

I don't think we want to duplicate the nonzero structure, so maybe just allocate a fresh matrix rather than calling similar.

Note that there is also a MatDiagonalSet, though I doubt it has any advantage over MatSetValues in this case.

@kshyatt
Copy link
Contributor

kshyatt commented Dec 4, 2015

Wait - do you want ones(M), or eye(M)? I thought ones preserved the non-zero structure but set all values to one(T)?

@stevengj
Copy link
Contributor Author

stevengj commented Dec 4, 2015

I want one(M) = eye(M), not ones(M).

@stevengj
Copy link
Contributor Author

stevengj commented Dec 4, 2015

I should also mention diag(M) and diagm(v) via MatDiagonalSet/Get, while it is on my mind.

@kshyatt
Copy link
Contributor

kshyatt commented Dec 4, 2015

Aha! Then in that case, I agree that MatDuplicate isn't at all what we want :). I think I wrapped diag(M) using MatDiagonalGet but I didn't do diagm.

@stevengj
Copy link
Contributor Author

stevengj commented Dec 4, 2015

ones(M) does not preserve the non-zero structure, it just makes a matrix of all 1's. I don't think it is particularly useful in the case of PETSc. Also, I think it already works, because the default implementation probably calls fill!?

@kshyatt
Copy link
Contributor

kshyatt commented Dec 4, 2015

Oh god, I was confused between one and ones.

@stevengj
Copy link
Contributor Author

stevengj commented Dec 4, 2015

Hmm, looks like ones(M::Mat) gives garbage.

@jkozdon jkozdon closed this as completed Jul 1, 2021
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

3 participants