Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file owl_operator.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201# 1 "src/base/core/owl_operator.ml"(*
* OWL - OCaml Scientific Computing
* Copyright (c) 2016-2022 Liang Wang <liang@ocaml.xyz>
*)(** Operator definition such as add, sub, mul, and div. *)openOwl_types_operator(* define basic operators *)moduleMake_Basic(M:BasicSig)=structtype('a,'b)op_t0=('a,'b)M.tlet(+)=M.addlet(-)=M.sublet(*)=M.mullet(/)=M.divlet(+$)=M.add_scalarlet(-$)=M.sub_scalarlet(*$)=M.mul_scalarlet(/$)=M.div_scalarlet($+)=M.scalar_addlet($-)=M.scalar_sublet($*)=M.scalar_mullet($/)=M.scalar_divlet(=)=M.equallet(!=)=M.not_equallet(<>)=M.not_equallet(>)=M.greaterlet(<)=M.lesslet(>=)=M.greater_equallet(<=)=M.less_equalend[@warning"-34"]moduleMake_Extend(M:ExtendSig)=structtype('a,'b)op_t1=('a,'b)M.tlet(=$)=M.equal_scalarlet(!=$)=M.not_equal_scalarlet(<>$)=M.not_equal_scalarlet(<$)=M.less_scalarlet(>$)=M.greater_scalarlet(<=$)=M.less_equal_scalarlet(>=$)=M.greater_equal_scalarlet(=.)=M.elt_equallet(!=.)=M.elt_not_equallet(<>.)=M.elt_not_equallet(<.)=M.elt_lesslet(>.)=M.elt_greaterlet(<=.)=M.elt_less_equallet(>=.)=M.elt_greater_equallet(=.$)=M.elt_equal_scalarlet(!=.$)=M.elt_not_equal_scalarlet(<>.$)=M.elt_not_equal_scalarlet(<.$)=M.elt_less_scalarlet(>.$)=M.elt_greater_scalarlet(<=.$)=M.elt_less_equal_scalarlet(>=.$)=M.elt_greater_equal_scalarlet(=~)=M.approx_equallet(=~$)=M.approx_equal_scalarlet(=~.)=M.approx_elt_equallet(=~.$)=M.approx_elt_equal_scalarlet(%)=M.fmodlet(%$)=M.fmod_scalarlet(**)=M.powlet($**)=M.scalar_powlet(**$)=M.pow_scalarlet(+=)xy=M.add_~out:xxylet(-=)xy=M.sub_~out:xxylet(*=)xy=M.mul_~out:xxylet(/=)xy=M.div_~out:xxylet(+$=)xa=M.add_scalar_~out:xxalet(-$=)xa=M.sub_scalar_~out:xxalet(*$=)xa=M.mul_scalar_~out:xxalet(/$=)xa=M.div_scalar_~out:xxalet(@=)=M.concat_verticallet(@||)=M.concat_horizontallet(.!{;..})xs=M.get_fancy_extsxlet(.!{;..}<-)xs=M.set_fancy_extsxlet(.${})xs=M.get_slice_ext[|s|]xlet(.${;..})xs=M.get_slice_extsxlet(.${}<-)xs=M.set_slice_ext[|s|]xlet(.${;..}<-)xs=M.set_slice_extsxend[@warning"-34"]moduleMake_Matrix(M:MatrixSig)=structtype('a,'b)op_t2=('a,'b)M.tlet(.%{})x(i1,i2)=M.getxi1i2let(.%{;..})xi=ifArray.lengthi=2thenM.getxi.(0)i.(1)elsefailwith(".%{} on matrices requires exactly two indices but I got "^string_of_int@@Array.lengthi)let(.%{}<-)x(i1,i2)=M.setxi1i2let(.%{;..}<-)xi=ifArray.lengthi=2thenM.setxi.(0)i.(1)elsefailwith(".%{}<- on matrices requires exactly two indices but I got "^string_of_int@@Array.lengthi)let(*@)ab=M.dotabend[@warning"-34"]moduleMake_Ndarray(M:NdarraySig)=structtype('a,'b)op_t3=('a,'b)M.tlet(.%{})xi=M.getx[|i|]let(.%{;..})xi=M.getxilet(.%{}<-)xi=M.setx[|i|]let(.%{;..}<-)xi=M.setxiend[@warning"-34"]moduleMake_Linalg(M:LinalgSig)=structtype('a,'b)op_t4=('a,'b)M.tlet(**@)xa=M.mpowxalet(/@)ab=M.linsolveabend[@warning"-34"](* ends here *)