/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: y_ixch.c,v 1.2 1997/09/25 18:25:52 ae59 Exp $ */
/*
$Log: y_ixch.c,v $
 * Revision 1.2  1997/09/25  18:25:52  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:25:57  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : y_ixch.c                              */
/*                                                              */
/*      Entry           : a_btyp y_ixch(index,range)            */
/*                        a_intg index;                         */
/*                        y_bnds range;                         */
/*                                                              */
/*      Arguments       : index  - index of element             */
/*                        range  - range of dimension           */
/*                                                              */
/*      Return value    : offset to indexed element             */
/*                                                              */
/*      Description     : check for valid index and determine   */
/*                        offset to indexed element.            */
/*                                                              */
/*      Date            : 1990-11-12                            */
/*      1990-11-12 : E_TPUSH+E_TPOPP                            */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
#endif

#ifdef LINT_ARGS
local a_btyp y_ixch(a_intg index,y_bnds range)
#else
local a_btyp y_ixch(index,range)

a_intg index;
y_bnds range;
#endif
        {
        E_TPUSH("y_ixch")

        if (index<range.lbound || index>range.ubound)
           {
           e_trap(INDEX_RANGE,6,
                  E_TINT+E_TEXT(4),&index,
                  E_TINT+E_TEXT(5),&range.lbound,
                  E_TINT+E_TEXT(6),&range.ubound);
           }

        E_TPOPP("y_ixch")
        return((index-range.lbound)*range.stride);
        }
