Skip to content

Commit fea8bdf

Browse files
committed
add right scalar multiplication instances on DataArrayN
1 parent da00ea6 commit fea8bdf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

SciLean/Data/DataArray/Algebra.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ instance [HasRnEquiv X K R] : Module R (X^[I]) := by infer_instance
5353
instance [HasRnEquiv X K R] : TopologicalSpace (X^[I]) := by infer_instance
5454

5555

56+
-- TODO: change definitino of `AdjointSpace` to require `SMul (Rᵐᵒᵖ) X` and
57+
-- complex conjugation fow which I use `Star X` right now but it is not a good choice
58+
-- as it would clash with conjugate-transpose for matrices
59+
instance [HasRnEquiv X K R] : SMul (Rᵐᵒᵖ) (X^[I]) := ⟨fun r x => r.1•x⟩
60+
instance [HasRnEquiv X K R] : Star (X^[I]) := ⟨fun x => x⟩
61+
62+
5663
instance [HasRnEquiv X K R] : Axpby R (X^[I]) where
5764
axpby a x b y :=
5865
let data := BLAS.LevelOneDataExt.axpby nI a (toRn x).1 0 1 b (toRn y).1 0 1

Test/basic_vec_fwd_fderiv.lean

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ set_default_scalar Float
1414
rewrite_by
1515
lsimp -zeta only [simp_core, ↓vecFwdFDeriv_simproc]
1616

17-
-- todo: make these instances general
18-
instance {I nI} [IndexType I nI] : SMul Floatᵐᵒᵖ (Float^[I]) := ⟨fun x v => x.1 • v⟩
19-
instance {I nI} [IndexType I nI] : Star (Float^[I]) := ⟨fun x => x⟩
20-
2117
/--
2218
info: fun x dx => (‖x‖₂², vecMatMulAdd 2 x dx 0 0) : Float^[3] → Float^[3, 3] → Float × Float^[3]
2319
-/

0 commit comments

Comments
 (0)