.. _ogn_tutorial_generic_math_node:

Tutorial 26 - Generic Math Node
================================

This tutorial demonstrates how to compose nodes that perform mathematical operations in python using numpy. Using numpy 
has the advantage that it is api-compatible to cuNumeric. As demonstrated in the Extended Attributes tutorial, generic math nodes 
use extended attributes to allow inputs and outputs of arbitrary numeric types, specified using the "numerics" keyword. 

.. code-block:: json

    "inputs": {
        "myNumbericAttribute": {
            "description": "Accepts an incoming connection from any type of numeric value",
            "type": ["numerics"]
        }
    }

OgnTutorialGenericMathNode.ogn
--------------------------------
The *ogn* file shows the implementation of a node named "omni.graph.tutorials.GenericMathNode", which takes inputs
of any numeric types and performs a multiplication. 

.. literalinclude:: OgnTutorialGenericMathNode.ogn
    :linenos:
    :language: json

OgnTutorialGenericMathNode.py
---------------------------------
The *py* file contains the implementation of the node. It takes two numeric inputs and performs a multiplication,
demonstrating how to handle cases where the inputs are both numeric types but vary in precision, format or 
dimension.

.. literalinclude:: OgnTutorialGenericMathNode.py
    :linenos:
    :language: python
