-
Notifications
You must be signed in to change notification settings - Fork 18
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
Decomposition - symmetric and anti-symmetric #62
base: master
Are you sure you want to change the base?
Conversation
Decompose a quadratic equation into symmetric, antisymmetric parts using its transpose.
@ehuan2 Hi Eric, for some reason I cannot add you as the reviewer. Please take a look at my work. Thank you. |
Hi @AnhMai-bit the first thing I'll ask you to do is to remove all the |
Removed comments, all coefficients defined in one line.
Hi @ndattani, I updated the file just now. |
Excellent! I'll take a deeper look on Tuesday. Now I'm preparing for a talk I'll be giving in Montreal tomorrow :) |
Best of luck with your talk insert lucky clover ! Please also send me the link to the event if online registration is available, I would like to check it out :). |
b1 = b(:,1); b2 = b(:,2); b3 = b(:,3); b4 = b(:,4); | ||
|
||
f=b1.*b2 + b2.*b3 + b3.*b4 - 4*b1.*b2.*b3; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if this example had the following:
- 1 linear term with a coefficient of +1,
- 1 quadratic terms with a coefficient of +2,
- 1 cubic term with a coefficient of -4, and
- one quartic term with a coefficient of +2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add that asap.
|
||
f_sym = (1/2)*(f + f.'); | ||
f_anti = (1/2)*(f - f.'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes no sense. I don't see why you did f.'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to make the transpose of the matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ndattani my alternative solution is below. I will add that to the code if you approve.
% f_sym = (1/2)(f(b) + (1-f(b))
f_sym = (1/2)(f + (1-f))
% f_anti = (1/2)(f(b) - (1-f(b))
f_anti = (1/2)(f - (1-f))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone who has used MATLAB for as long as me would know that f.'
does the transpose of f
, but what made you think that it would be a good idea to do the transpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into how decomposition into symmetric and antisymmetric would be and I see there are 2 ways to do it. One this by adding and subtracting transpose into f, divided by two. Source: https://www.mathworks.com/matlabcentral/answers/401295-how-to-find-the-symmetric-and-skew-symmetric-part-of-a-specified-matrix.
The other is from the paper attached to the part in the book: https://www.maths.lth.se/matematiklth/vision/publdb/reports/pdf/kahl-strandmark-iccv-11.pdf. Notation: f - (1-transpose of f), divided by 2.
Can you please explain the difference between those 2? Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second example doesn't use the transpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like I confused myself somewhere, my apologies. I will fix that tomorrow since I currently have to prepare to move.
Updated new function, coefficients and calculation for symmetry and antisymmetry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Anh Mai!
The example looks great, and you've almost verified it correctly! My suggestion is to check that the solutions for f_anti and f_sym actually work by:
- Creating new variables that represent the two that we want to check (ie f is the same as f_sym + f_anti)
- Assign these the values that we want to check for b1, b2, b3, b4. Remember that we want to check that the solution, ie the minimum values for them, are the same on both sides. A good way to check this is by taking a look at the pairwise example right above your changes.
Oh I forgot to mention! Feel free to also edit the latex file with your example! Now that it's verified on MatLab, you can edit the |
Thank you so much Eric. I will update it today. I will let you know on discord if I have more questions. |
everything_else/reproducing.m
Outdated
f_sym = (1/2)*(f + (1 - f)); | ||
f_anti = (1/2)*(f - (1 - f)); | ||
|
||
f_new = f_sym + f_anti; | ||
|
||
LHS=min(reshape(f_new,[])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
So this commit is almost good, but I'd suggest you trying to run this code in the MatLab environment (https://matlab.mathworks.com/, should be free for UWaterloo ppl) and you'll discover that your reshape function is incorrectly used (take a look at the reference here: https://www.mathworks.com/help/matlab/ref/reshape.html). Let me know if you have any questions!
Corrected reshape functions.
Alright I think I might've actually given bad advice - I think I forgot what the use of reshape is (and realizing I messed this up myself!). So, reshape is used to rearrange the output values we get into a matrix where we only care about the minimum in each row. So a good example is if we take a look at pg. 52 of the pdf, we get the example of ba_1 = b1b3, ba_2 = b2b4. In this case, we can see from the output of what b looks like in matlab, that each 4 rows have the same first b1...b4. This means that when we do reshape, we're essentially saying we don't care about what values we get for ba1, ba2 (since we group them together), we just care about the minimum that we get overall (since ba1 and ba2 are not actually variables we want to depend on). So, in your case, think about whether or not there are any of these redundant ba's we need to get rid of. Is there any b_i that we can do without? (If not, then we don't need a reshape/min!). I'm not 100% sure, so @ndattani can probably help me double check. |
I like that we have an example function:
Now it's time to write that function as a sum of |
Updated decomposition method, used NTR - KZFD and SFR-BCR-1.
Hey @AnhMai-bit ! Looks good to me! Feel free to edit the .tex with the equations (suggest to add in the quadratization for the symmetric and anti-symmetric part) and then the full example together. Let me know if you need help on this part. Feel free to merge after Dr. Dattani's approval! |
Thank you for your feedback @ehuan2. I will start adding to the text file after the solution is approved. |
Decompose a quadratic equation into symmetric, antisymmetric parts using its transpose.