-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The dot product should conjugate the second vector.
Matrix multiplication, on the other hand, should not take a complex conjugate, so shouldn't use the dot product for its definition -- just use sum(_.*_) instead. I'm really not sure that dot product makes any sense for anything that's not a vector so get rid of the definition for non-vectors. It doesn't seem to be used anywhere, so this is safe. Closes #51.
- Loading branch information
1 parent
9b628fd
commit 5807981
Showing
1 changed file
with
3 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
## linalg.j: Basic Linear Algebra functions ## | ||
|
||
dot(x::Vector, y::Vector) = sum(x.*y) | ||
# Take care of dot product of vectors that are actually matrices or N-d | ||
dot(x::Matrix, y::Matrix) = dot(reshape(x, prod(size(x))), reshape(y, prod(size(y))) ) | ||
dot(x::Vector, y::Vector) = sum(x.*conj(y)) | ||
|
||
# blas.j defines these for floats; this handles other cases | ||
(*)(A::Matrix, B::Vector) = [ dot(A[i,:],B) | i=1:size(A,1) ] | ||
(*)(A::Matrix, B::Matrix) = [ dot(A[i,:],B[:,j]) | i=1:size(A,1), j=1:size(B,2) ] | ||
(*)(A::Matrix, B::Vector) = [ A[i,:].*B | i=1:size(A,1) ] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
StefanKarpinski
Author
Member
|
||
(*)(A::Matrix, B::Matrix) = [ A[i,:].*B[:,j] | i=1:size(A,1), j=1:size(B,2) ] | ||
|
||
triu(M) = triu(M,0) | ||
tril(M) = tril(M,0) | ||
|
1 comment
on commit 5807981
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.
Oops. This closes issue #92. I'm not sure what crack I was smoking.
needs
sum()