rsspice 0.1.0

Pure Rust port of the SPICE Toolkit for space geometry
Documentation
//
// GENERATED FILE
//

use super::*;
use crate::SpiceContext;
use f2rust_std::*;

/// Maximum element of array, integer
///
/// Locate the maximum element of an integer array.
///
/// # Brief I/O
///
/// ```text
///  VARIABLE  I/O  DESCRIPTION
///  --------  ---  -------------------------------------------------
///  ARRAY      I   Array.
///  NDIM       I   Number of elements in ARRAY.
///  MAXVAL     O   Maximum value in ARRAY.
///  LOC        O   Location of MAXVAL in ARRAY.
/// ```
///
/// # Detailed Input
///
/// ```text
///  ARRAY    is an arbitrary array.
///
///  NDIM     is the number of elements in ARRAY.
/// ```
///
/// # Detailed Output
///
/// ```text
///  MAXVAL   is the value in array that is greater than or equal
///           to all other values in the array. If the array
///           contains more than one element with this value,
///           the first one is returned.
///
///           Elements in character arrays are compared according
///           to the ASCII collating sequence.
///
///  LOC      is the location of the maximum element. That is,
///           MAXVAL contains element ARRAY(LOC).
/// ```
///
/// # Exceptions
///
/// ```text
///  Error free.
///
///  1)  If the array is empty (NDIM is less than one), LOC is zero,
///      and MAXVAL is not changed.
/// ```
///
/// # Examples
///
/// ```text
///  Let array A contain the following elements.
///
///     A(1) = 16
///     A(2) =  4
///     A(3) = 32
///     A(4) = 64
///     A(5) =  2
///     A(6) =  8
///
///  Then following the call
///
///     CALL MAXAI ( A, 6, MAXVAL, LOC )
///
///  the values of MAXVAL and LOC are 64 and 4 respectively.
/// ```
///
/// # Author and Institution
///
/// ```text
///  J. Diaz del Rio    (ODC Space)
///  W.L. Taber         (JPL)
///  I.M. Underwood     (JPL)
/// ```
///
/// # Version
///
/// ```text
/// -    SPICELIB Version 1.1.0, 14-APR-2021 (JDR)
///
///         Added IMPLICIT NONE statement.
///
///         Edited the header to comply with NAIF standard. Removed
///         unnecessary $Revisions section.
///
/// -    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
///
///         Comment section for permuted index source lines was added
///         following the header.
///
/// -    SPICELIB Version 1.0.0, 31-JAN-1990 (IMU)
/// ```
pub fn maxai(array: &[i32], ndim: i32, maxval: &mut i32, loc: &mut i32) {
    MAXAI(array, ndim, maxval, loc);
}

//$Procedure MAXAI  ( Maximum element of array, integer )
pub fn MAXAI(ARRAY: &[i32], NDIM: i32, MAXVAL: &mut i32, LOC: &mut i32) {
    let ARRAY = DummyArray::new(ARRAY, 1..);

    //
    // Local variables
    //

    if (NDIM <= 0) {
        *LOC = 0;
        return;
    }

    *MAXVAL = ARRAY[1];
    *LOC = 1;

    for I in 2..=NDIM {
        if (ARRAY[I] > *MAXVAL) {
            *MAXVAL = ARRAY[I];
            *LOC = I;
        }
    }
}