Fix model for multiply
- 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
Assessment
This issue has not been assessed yet.