Into

Modules

Documentation

classPiiArithmeticOperation

#include <PiiArithmeticOperation.h>

An operation that performs simple arithmetic like adding and subtracting values.

Inherits PiiDefaultOperation

Description

Inputs

input0first operand. Any matrix or scalar type.
input1second operand (optional). If this input is not connected, the second operand will initialized to a constant value. The default constant value is a zero (double). Note that if this input is a matrix, input0 must also be a matrix.

Outputs

outputthe type of the output is a combination of the inputs. For example, if input0 is PiiMatrix<int> and input1 is double, output type is PiiMatrix<double>. If both types are the same, no type change will be made.

Properties

A constant value for the input1.

The arithmetic operator to be used.

Public types

enum
{ Plus, Minus, Division, Multiplication, ElementMultiplication, ElementDivision }

Known arithmetic functions.

Constructors and destructor

Public member functions

virtual void
(
  • bool reset
)

Checks the operation for execution.

void
( )
void
( )

Protected member functions

virtual void

Executes one round of processing.

Property details

  • PiiVariant constant

    [read, write]

    A constant value for the input1.

    If input1 is not connected, the second operand is this constant value.

  • Function function

    [read, write]

    The arithmetic operator to be used.

    Default value is Plus.

Enumeration details

  • enum Function

    Known arithmetic functions.

    We can't use "operator", because it is reserved by C++.

    • Plus - addition

    • Minus - subtraction

    • Division - division

    • Multiplication - multiplication

    • ElementMultiplication - multiply matrices element-by-element (see Pii::multiply()). This operator applies only to two matrices. For other types, ordinary multiplication will be used.

    • ElementDivision - divide matrices element-by-element (see Pii::divide()). This operator applies only to two matrices. For other types, ordinary division will be used.

Function details

  • PiiArithmeticOperation

    ()
  • virtual void check

    (
    • bool reset
    )
    [virtual]

    Checks the operation for execution.

    This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.

    If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.

    Reimplemented from PiiDefaultOperation.

  • PiiVariant constant

    ()
  • Function function

    ()
  • void setConstant

    ( )
  • void setFunction

    ( )
  • virtual void process

    ()
    [protected, virtual]

    Executes one round of processing.

    This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.

    Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().

    Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns Running.

    Exceptions
    PiiExecutionException

    whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.

    Reimplemented from PiiDefaultOperation.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.