## arithmetic

arithmetic — Arithmetic opetations on data fields

## Synopsis

    #include <libprocess/gwyprocess.h>

    void                gwy_data_field_sum_fields           (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);
    void                gwy_data_field_subtract_fields      (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);
    void                gwy_data_field_divide_fields        (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);
    void                gwy_data_field_multiply_fields      (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);
    void                gwy_data_field_min_of_fields        (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);
    void                gwy_data_field_max_of_fields        (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);
    GwyDataCompatibilityFlags gwy_data_field_check_compatibility
                                                            (GwyDataField *data_field1,
                                                             GwyDataField *data_field2,
                                                             GwyDataCompatibilityFlags check);
    GwyDataCompatibilityFlags gwy_data_line_check_compatibility
                                                            (GwyDataLine *data_line1,
                                                             GwyDataLine *data_line2,
                                                             GwyDataCompatibilityFlags check);

## Description

Data arithmetic functions perform simple operations combining several data fields. Their sizes have to be size-compatible, i.e. gwy_data_field_check_compatibility(operand1, operand2, GWY_DATA_COMPATIBILITY_RES) must pass and the same must hold for the data field to store the result to.

Functions `gwy_data_field_check_compatibility()` and `gwy_data_line_check_compatibility()` simplify testing compatibility of data fields and lines, respectively.

## Details

### gwy_data_field_sum_fields ()

    void                gwy_data_field_sum_fields           (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);

Sums two data fields.

`result` : | A data field to put the result to. May be one of `operand1`, `operand2`.
`operand1` : | First data field operand.
`operand2` : | Second data field operand.

### gwy_data_field_subtract_fields ()

    void                gwy_data_field_subtract_fields      (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);

Subtracts one data field from another.

`result` : | A data field to put the result to. May be one of `operand1`, `operand2`.
`operand1` : | First data field operand.
`operand2` : | Second data field operand.

### gwy_data_field_divide_fields ()

    void                gwy_data_field_divide_fields        (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);

Divides one data field with another.

`result` : | A data field to put the result to. May be one of `operand1`, `operand2`.
`operand1` : | First data field operand.
`operand2` : | Second data field operand.

### gwy_data_field_multiply_fields ()

    void                gwy_data_field_multiply_fields      (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);

Multiplies two data fields.

`result` : | A data field to put the result to. May be one of `operand1`, `operand2`.
`operand1` : | First data field operand.
`operand2` : | Second data field operand.

### gwy_data_field_min_of_fields ()

    void                gwy_data_field_min_of_fields        (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);

Finds point-wise maxima of two data fields.

`result` : | A data field to put the result to. May be one of `operand1`, `operand2`.
`operand1` : | First data field operand.
`operand2` : | Second data field operand.

### gwy_data_field_max_of_fields ()

    void                gwy_data_field_max_of_fields        (GwyDataField *result,
                                                             GwyDataField *operand1,
                                                             GwyDataField *operand2);

Finds point-wise minima of two data fields.

`result` : | A data field to put the result to. May be one of `operand1`, `operand2`.
`operand1` : | First data field operand.
`operand2` : | Second data field operand.

### gwy_data_field_check_compatibility ()

    GwyDataCompatibilityFlags gwy_data_field_check_compatibility
                                                            (GwyDataField *data_field1,
                                                             GwyDataField *data_field2,
                                                             GwyDataCompatibilityFlags check);

Checks whether two data fields are compatible.

`data_field1` : | A data field.
`data_field2` : | Another data field.
`check` : | The compatibility tests to perform.
Returns : | Zero if all tested properties are compatible. Flags corresponding to failed tests if data fields are not compatible.

### gwy_data_line_check_compatibility ()

    GwyDataCompatibilityFlags gwy_data_line_check_compatibility
                                                            (GwyDataLine *data_line1,
                                                             GwyDataLine *data_line2,
                                                             GwyDataCompatibilityFlags check);

Checks whether two data lines are compatible.

`data_line1` : | A data line.
`data_line2` : | Another data line.
`check` : | The compatibility tests to perform.
Returns : | Zero if all tested properties are compatible. Flags corresponding to failed tests if data lines are not compatible.