Skip to content

Tutorial: Operators and Ext Module

Liang Wang edited this page May 1, 2017 · 19 revisions

This tutorial will go through the operators and Ext module. The operators in Owl are implemented using functors. However, you do not need to work with functors directly in order to use the operators.

Basic Operators

The operators have been included in each Ndarray and Matrix module. The following table summarises the operators currently implemented in Owl.

Operator Example Operation Dense/Sparse Ndarray/Matrix
+ x + y element-wise add both both
- x - y element-wise sub both both
* x * y element-wise mul both both
/ x / y element-wise div both both
+$ x +$ a add scalar both both
-$ x -$ a sub scalar both both
*$ x *$ a mul scalar both both
/$ x /$ a div scalar both both
$+ a $+ x scalar add both both
$- a $- x scalar sub both both
$* a $* x scalar mul both both
$/ a $/ x scalar div both both
= x = y comparison both both
!= x != y comparison both both
<> x <> y same as != both both
> x > y comparison both both
< x < y comparison both both
>= x >= y comparison both both
<= x <= y comparison both both
=. x =. y comparison Dense both
!=. x !=. y comparison Dense both
<>. x <>. y same as !=. Dense both
>. x >. y comparison Dense both
<. x <. y comparison Dense both
>=. x >=. y comparison Dense both
<=. x <=. y comparison Dense both
** x ** y power function Dense both
*@ x *@ y matrix multiply both Matrix