Skip to content

Fix model for multiply #113

@sloorush

Description

@sloorush

New proposed model, needs some fixes

    complexMultiplyModel←{
        (⎕FR≡1287) ∧ case≡'Hcmplx': ⍺×⍵ ⍝ Skipping cmplx for ⎕FR←1287
        a c b d←∊(9 11○⊂)⍺ ⍵ 
        ⍝ using formula (a+bi)(c+di)=(ac−bd)+(ad+bc)i
        x←((a model c)-(b model d))
        y←((a model d)+(b model c))
        x(⊣+¯11○⊢)y
    }
 
    ⍝ model←{*(⍟⍺)+⍟⍵}
    model←{⍺{
            ⍝ ⍺ or ⍵ being 0 will give 0
            0≡⍵:0
            0≡⍺:0
            ⍝ isCmplx
            ⍝ ((⊢≠+)⍺)∨((⊢≠+)⍵): r←*(⍟⍺)+⍟⍵
            (1289≡⎕DR ⍵) ∨ (1289≡⎕DR ⍺): ⍺ complexMultiplyModel¨ ⍵
            ⍝ ⎕←(⌹¨÷/×⍺ ⍵)
            r←*(⍟|⍺)+⍟|⍵
            ⍝ if 1 negative number negate the output
            1≡+/¯1⍷×⍺ ⍵:-r⋄r
        }¨⍵
    }
          Could you use {*(⍟⍺)+⍟⍵} as the model (using logarithms instead)? This would remove the need to handle complex numbers specifically.

Or, alternatively, could you use multiple models for redundancy?

Originally posted by @definitelyprobably in #76 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions