Last active
December 30, 2015 19:19
-
-
Save luxbock/7873465 to your computer and use it in GitHub Desktop.
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
(extend-protocol mp/PExponent | |
Number | |
(element-pow [m exponent] | |
(Math/pow (.doubleValue m) (double exponent))) | |
Object | |
(element-pow [m exponent] | |
(let [x (double exponent)] | |
(mp/element-map m #(Math/pow (.doubleValue ^Number %) x))))) |
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
(defprotocol PMatrixEquality | |
"Protocol for numerical array equality operations." | |
(matrix-equals [a b] | |
"Return true if a equals b, i.e. if a and b are have the same shape and all elements are equal. | |
Must use numerical value comparison on numbers (==) to account for matrices that may hold a mix of | |
numercial types (e.g. java.lang.Long and java.lang.Double). Implementations that only support doubles | |
should use Number.doubleValue() to get a numeric value to compare. | |
May throw an exception if the matrices are non-numeric")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment