|
FUNCTION regular_indexing (sub : LIST [0:?] OF INTEGER, base : zero_or_one, shape : LIST [1:?] OF positive_integer, inc : LIST [1:?] OF INTEGER, first : INTEGER) : INTEGER; LOCAL k : INTEGER ; index : INTEGER ; END_LOCAL ; IF NOT EXISTS ( sub ) OR NOT EXISTS ( base ) OR NOT EXISTS ( shape ) OR NOT EXISTS ( inc ) OR NOT EXISTS ( first ) THEN RETURN ( ? ) ; END_IF ; IF ( SIZEOF ( sub ) <> SIZEOF ( inc ) ) OR ( SIZEOF ( sub ) <> SIZEOF ( shape ) ) THEN RETURN ( ? ) ; END_IF ; index := first ; REPEAT j := 1 TO SIZEOF ( sub ) ; IF NOT EXISTS ( sub [ j ] ) OR NOT EXISTS ( inc [ j ] ) THEN RETURN ( ? ) ; END_IF ; k := sub [ j ] - base ; IF NOT ( { 0 <= k < shape [ j ] } ) THEN RETURN ( ? ) ; END_IF ; index := index + k * inc [ j ] ; END_REPEAT ; RETURN ( index ) ; END_FUNCTION; -- regular_indexing |
|
public class FRegular_indexing public static Value run(SdaiContext _context, Value sub, Value base, Value shape, Value inc, Value first) |