Dyalog / Dyalog/ullu

Fix model for multiply

Open
#113 0 comments 0 reactions 0 assignees View on GitHub
refactor
Dominant language
APL
Stars
5
Forks
4
PR merge metrics
No merged PRs in 30d

Description

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 https://github.com/Dyalog/ullu/pull/76#discussion_r1880465177_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.