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

is_sdd function on HW1 #34

Open
LaTournesol opened this issue May 5, 2016 · 1 comment
Open

is_sdd function on HW1 #34

LaTournesol opened this issue May 5, 2016 · 1 comment
Labels

Comments

@LaTournesol
Copy link

LaTournesol commented May 5, 2016

Hi there,
I was just reviewing my comments for the first homework and it simply said that my is_sdd function is incorrect without any explanation. However I tested it multiple times and it worked fine.
def is_sdd(A): d_min = min(diag(A)) # the minimum value on the diagonal U = triu(A, 1) L = tril(A, -1) return (d_min > U).all() and (d_min > L).all()
Here is the function, It's very short so I just pasted it here.
Basically I first find the minimum value on the diagonal, and then test if this min is greater than every other non diagonal entries, it return true if the min is greater than every other non diagonal entry.
Can you tell me why is it incorrect?
Thanks!

@quantheory
Copy link
Member

Ah, right. I think the issue is that you did not take the absolute value of the matrix elements. For instance, the following matrix is SDD:

-3 1 1
1 -3 1
1 1 -3

I don't think that your code correctly determines this.

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

No branches or pull requests

3 participants