Skip to documentation
DocumentationAll documentsEnglish

DMOD(1)

NAME

dmod - apply arithmetic operations to a stream of doubles

On this page

SYNOPSIS

dmod [-a add] [-s sub] [-m mult] [-d div] [-A] [-e exp] [-r root] [doubles]

DESCRIPTION

dmod reads a stream of 64-bit double-precision floating-point numbers, applies one or more arithmetic operations to every value, and writes the modified doubles to standard output.

Any number of add, subtract, multiply, divide, absolute value, or exponentiation operations may be given on the command line. They are applied to each value in the order they appear, so the operations form a left-to-right pipeline.

If a file argument is supplied, dmod reads from it; otherwise it reads from standard input. Both the input and output are raw binary doubles, so the standard input and output must not be a terminal. See dconv(1) and d-i(1) for converting between doubles and other numeric formats.

OPTIONS

-a val

Add val to each number.

-s val

Subtract val from each number.

-m val

Multiply each number by val.

-d val

Divide each number by val. A val of zero is rejected.

-A

Replace each number with its absolute value.

-e val

Raise each number to the power val.

-r val

Take the val-th root of each number (raise to the power 1/val). A val of zero is rejected.

-h, -?

Print a usage message and exit.

EXAMPLES

Example 1. Rescale a height field to inches and clamp negatives
dmod -m 0.0393701 -A terrain_mm.d > terrain_in_pos.d

Reads doubles from terrain_mm.d (values in millimeters), multiplies each by 0.0393701 to convert to inches, then takes the absolute value to remove any negative elevations, writing the result to terrain_in_pos.d. Operations are applied left to right, so the scaling happens before the absolute value.

SEE ALSO

brlcad(1), dconv(1), d-i(1), d-f(1)

AUTHOR

BRL-CAD Team

This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.

BUG REPORTS

Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org