-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic operations on vectors and matrices
- Loading branch information
Showing
14 changed files
with
889 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import SciLean.Data.DataArray.Operations.Multiply | ||
|
||
namespace SciLean | ||
|
||
section Missing | ||
|
||
|
||
theorem sum_over_prod' {R} [AddCommMonoid R] {I J : Type*} [IndexType I] [IndexType J] | ||
{f : I → J → R} : ∑ i j, f i j = ∑ (i : I×J), f i.1 i.2 := sorry | ||
|
||
theorem sum_over_prod {R} [AddCommMonoid R] {I J : Type*} [IndexType I] [IndexType J] | ||
{f : I×J → R} : ∑ i, f i = ∑ i j, f (i,j) := sorry | ||
|
||
@[rsimp] | ||
theorem sum_ite {R} [AddCommMonoid R] {I : Type*} [IndexType I] [DecidableEq I] | ||
{f : I → R} (j : I) : (∑ i, if i = j then f i else 0) = f j := sorry | ||
|
||
@[rsimp] | ||
theorem sum_ite' {R} [AddCommMonoid R] {I : Type*} [IndexType I] [DecidableEq I] | ||
{f : I → R} (j : I) : (∑ i, if j = i then f i else 0) = f j := sorry | ||
|
||
theorem sum_swap {R} [AddCommMonoid R] {I J : Type*} [IndexType I] [IndexType J] | ||
{f : I → J → R} : ∑ i j, f i j = ∑ j i, f i j := sorry | ||
|
||
end Missing | ||
|
||
|
||
variable | ||
{I : Type*} [IndexType I] [DecidableEq I] | ||
{R : Type*} [RealScalar R] [PlainDataType R] | ||
|
||
|
||
open DataArrayN | ||
|
||
def_fun_prop diag in x | ||
with_transitive : IsContinuousLinearMap R | ||
|
||
#generate_linear_map_simps DataArrayN.diag.arg_x.IsLinearMap_rule | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans diag in x : fderiv R by autodiff | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans diag in x : fwdFDeriv R by autodiff | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans diag in x : adjoint R by | ||
equals (fun x' => x'.diagonal) => | ||
funext x | ||
apply AdjointSpace.ext_inner_left R | ||
intro z | ||
rw[← adjoint_ex _ (by fun_prop)] | ||
simp[DataArrayN.inner_def,Function.HasUncurry.uncurry, | ||
DataArrayN.diag,DataArrayN.diagonal, | ||
sum_over_prod, sum_ite'] | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans diag in x : revFDeriv R by | ||
unfold revFDeriv | ||
autodiff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import SciLean.Data.DataArray.Operations.Diag | ||
|
||
namespace SciLean | ||
|
||
|
||
|
||
variable | ||
{I : Type*} [IndexType I] [DecidableEq I] | ||
{R : Type*} [RealScalar R] [PlainDataType R] | ||
|
||
open DataArrayN | ||
|
||
|
||
def_fun_prop diagonal in x | ||
with_transitive | ||
[RealScalar R] : IsContinuousLinearMap R | ||
|
||
#generate_linear_map_simps DataArrayN.diagonal.arg_x.IsLinearMap_rule | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans diagonal in x [RealScalar R] : fderiv R by | ||
fun_trans | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans diagonal in x [RealScalar R] : fwdFDeriv R by | ||
autodiff | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans diagonal in x [DecidableEq I] [RealScalar R] : adjoint R by | ||
equals (fun x' => x'.diag) => | ||
funext x | ||
apply AdjointSpace.ext_inner_left R | ||
intro z | ||
rw[← adjoint_ex _ (by fun_prop)] | ||
simp[DataArrayN.inner_def,Function.HasUncurry.uncurry, | ||
DataArrayN.diagonal,DataArrayN.diag, | ||
sum_over_prod, sum_ite'] | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans diagonal in x [DecidableEq I] [RealScalar R] : revFDeriv R by | ||
unfold revFDeriv | ||
autodiff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import SciLean.Data.DataArray.Operations.Diag | ||
|
||
namespace SciLean | ||
|
||
open DataArrayN | ||
|
||
def_fun_prop dot in x with_transitive : IsContinuousLinearMap R | ||
def_fun_prop dot in y with_transitive : IsContinuousLinearMap R | ||
def_fun_prop dot in x y with_transitive : Differentiable R | ||
|
||
#generate_linear_map_simps DataArrayN.dot.arg_x.IsLinearMap_rule | ||
#generate_linear_map_simps DataArrayN.dot.arg_y.IsLinearMap_rule | ||
|
||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans dot in x y : fderiv R by | ||
rw[fderiv_wrt_prod (by fun_prop)] | ||
fun_trans | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans dot in x y : fwdFDeriv R by | ||
rw[fwdFDeriv_wrt_prod (by fun_prop)] | ||
autodiff | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans dot in x : adjoint R by | ||
equals (fun z => z•y) => | ||
funext x | ||
apply AdjointSpace.ext_inner_left R | ||
intro z | ||
rw[← adjoint_ex _ (by fun_prop)] | ||
simp[DataArrayN.inner_def, DataArrayN.dot, | ||
sum_over_prod, Function.HasUncurry.uncurry, sum_pull] | ||
ac_rfl | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans dot in y : adjoint R by | ||
equals (fun z => z•x) => | ||
funext y | ||
apply AdjointSpace.ext_inner_left R | ||
intro z | ||
rw[← adjoint_ex _ (by fun_prop)] | ||
simp[DataArrayN.inner_def, DataArrayN.dot, | ||
sum_over_prod, Function.HasUncurry.uncurry, sum_pull] | ||
ac_rfl | ||
|
||
-- todo: change to abbrev_def_trans | ||
def_fun_trans dot in x y : revFDeriv R by | ||
rw[revFDeriv_wrt_prod (by fun_prop)] | ||
unfold revFDeriv | ||
autodiff |
Oops, something went wrong.