uwhpsc-2016 / syllabus

Spring 2016 Course Syllabus and Information
15 stars 20 forks source link

is_sdd function on HW1 #34

Open LaTournesol opened 8 years ago

LaTournesol commented 8 years ago

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 commented 8 years ago

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.