DVdata_math


Synopsis

perform mathematical operations on fields using V expressions


group DVdata_math {
string+IPort2 operation = "#1";
Mesh+Node_Data+IPort2+nonotify &in1;
Mesh+Node_Data+IPort2+nonotify &in2;
Mesh+Node_Data+IPort2+nonotify &in3;
Mesh+Node_Data+IPort2+nonotify &in4;
int+IPort2 data_type = 4;
Node_Data+write+nonotify out_nd {
nnodes+nres => in1.nnodes;
nnode_data = 1;
!node_data[0] {
&id+nres => in1.node_data[0].id;
&veclen+nres => in1.node_data[0].veclen;
prim values[nvals][veclen];
labels+nres = "data_math";
};
};
Mesh+Node_Data+nonotify+OPort2 &out => merge(out_nd,in1);
method+notify_val+notify_inst upd_data_math = "data_math";
};

Description

DVdata_math performs mathematical operations on one to four input fields. You supply any valid V expression and use the data_type input to set what data type you want the computation to be performed in.

Input

operation

A string containing any valid V mathematical expression, as described in the Developer's Reference manual. Do not enclose in quotes or terminate with ";".

For example:

sqrt( pow(#1,2) + pow(#2,2) + pow(#3,2) )

would calculate the magnitude of the 0th component of input fields 1, 2, and 3.

The default string is #1.

&inn

The input field(s) are references to fields with any type of mesh and Node_Data. You can use from 1 to 4 inputs. When typing the expression, you refer to them as #1, #2, #3, and #4.

DVdata_math uses the first (0th) component of each field. Operations between two fields require that their components be the same length (nnodes must be equal) and both components have the same veclen.

data_type

An integer to set the data type in which the computation will be performed. Each input's 0th component Node_Data is first converted to that type, the computation is performed in that type, and the output Node_Data is in that type. The choices are 0 (char), 1 (byte), 2 (short), 3 (int), 4 (float), and 5 (double). The default is 4 (float).

Output

&out

The output is a reference to a merged object that contains the new Node_Data that has the result of the computation. Its mesh is a reference to the input mesh of in1.

Files

v/dv.v
modules/dmath.c

Example

Libraries.Main.Filters.data_math

See also

The Developer's Reference manual for discussion of V mathematical expressions.