mrmustard.math

Backends

The math module contains low-level functions for performing mathematical operations.

It is recommended that users access the backends using the an instance of the Math class rather than the backends themselves.

The Math class is a wrapper that passes the calls to the currently active backend, which is determined by the BACKEND parameter in mrmustard.settings (the default is tensorflow).

The advantage of using the Math class is that the same code can run on different backends, allowing for a greater degree of flexibility and code reuse.

from mrmustard.math import Math
math = Math()
math.cos(x)  # tensorflow backend

from mrmustard import settings
settings.BACKEND = 'torch'

math.cos(x)  # torch backend

Classes

Math()

This class is a switcher for performing math operations on the currently active backend.

TFMath(*args, **kwargs)

Tensorflow implemantion of the Math interface.

Variables

settings

Settings class.

Class Inheritance Diagram

digraph inheritance377a2f6fd1 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [color=lightskyblue1,fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Helper class that provides a standard way to create an ABC using"]; "Math" [URL="api/mrmustard.math.Math.html#mrmustard.math.Math",color=lightskyblue1,fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,target="_top",tooltip="This class is a switcher for performing math operations on the currently active backend."]; "MathInterface" [color=lightskyblue1,fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="The interface that all backends must implement."]; "ABC" -> "MathInterface" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TFMath" [URL="api/mrmustard.math.tensorflow.TFMath.html#mrmustard.math.tensorflow.TFMath",color=lightskyblue1,fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,target="_top",tooltip="Tensorflow implemantion of the :class:`Math` interface."]; "MathInterface" -> "TFMath" [arrowsize=0.5,style="setlinewidth(0.5)"]; }