Use System Routines for Common Operations
PV-WAVE supplies a number of built-in functions and procedures to perform common operations. These system-supplied routines have been carefully optimized and are almost always much faster than writing an equivalent operation with loops and subscripting.
Example
A common operation is to find the sum of the elements in an array or subarray. The TOTAL function directly and efficiently evaluates this sum at least ten times faster than directly coding the sum:
; Slow way: Initialize SUM and sum each element.
SUM = 0. & FOR I = J, K DO SUM = SUM + ARRAY(I)
; Efficient, simple way.
SUM = TOTAL(ARRAY(J : K))
Using a 10,000-element floating-point vector and summing all of its elements took 4 seconds with the first statement and .09 seconds with the second.
Similar savings result when finding the minimum and maximum elements in an array (MIN and MAX functions), sorting (SORT function), finding zero or non-zero elements (WHERE function), etc.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.