Giter Site home page Giter Site logo

core.matrix.complex's Introduction

core.matrix.complex

A core.matrix imlementation for complex valued matrices.

Structure

Matrices are implemented as a real/imaginary matrix pairs, and by default operations are outsourced to the underlying matrices. This implies that users can use whatever core.matrix implementations they wish for the underlying matrices.

For example, matrix multiplication can be treated as:

(A + Bi) * (C + Di) = (AC - BD) + (AD + BC)i

Addition is even simpler:

(A + Bi) + (C + Di) = (A + C) + (B + D)i

This demonstrates that in many computational instances, we can benefit from performance characteristics of the underlying matrix implementations. More tailored algorithms and routines can of course be added as needed, as well as functions which would only pertain to complex valued matrices.

core.matrix.complex's People

Contributors

dmh43 avatar jmilum avatar metasoarous avatar mikera avatar sritchie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

core.matrix.complex's Issues

Comparing 0.0 and -0.0 during tests

While writing some tests for the PMatrixOps protocol, I've realized that 0.0 != -0.0 for Java doubles (see this stackoverflow question). Since complex numbers in Clojure ultimately just Java doubles, some tests that I've written which should pass, are reported as having failed.

;; from complex.core
(defn complex-number
  "..."
  ([^double a] (Complex. a))
  ([^double a ^double b] (Complex. a b)))

To get around this, I just add 0.0 but it seems ugly. Can anyone suggest a better way to do this? Is there a comparison function I can use which will map -0.0 to 0.0?

Here is an example of -0.0 showing up where 0.0 makes more sense.

(m/pm 
   (m/inverse 
      (cm/complex-array (m/identity-matrix 3))))
;;=>[[(1.0, -0.0) (0.0, -0.0) (0.0, -0.0)]
;;   [(0.0, -0.0) (1.0, -0.0) (0.0, -0.0)]
;;   [(0.0, -0.0) (0.0, -0.0) (1.0, -0.0)]]

Here is my part of test for the Hermitian Transpose function where I add 0.0 to each matrix element to coerce -0.0 to 0.0:

(deftest herm-transpose
  (is (m/e= (m/add (cm/hermitian-transpose
                     (cm/complex-array (m/identity-matrix 2))) (c/complex-number 0 0))
            (cm/complex-array (m/identity-matrix 2))))
;;...
)

This test returns passes, but I wonder if there is a better (more straightforward) way to do this.

Fix mmul for complex matrices

Current mmul is broken with core.matrix 0.50.0. Needs a fix to ensure that this works with complex numbers.

In the meantime, inner-product works as a replacement

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.