get_range_min.c

来自「稀疏矩阵、链表、图、队列、二叉树、多叉树、排序、遗传算法等的实现」· C语言 代码 · 共 52 行

C
52
字号
/**************************************************************************
**  SP_GET_RANGE_MIN                                                     **
**                                                                       **
**    Retrieve the minimum range value associated with a passed          **
**  dimension.                                                           **
**                                                                       **
**  INPUT:                                                               **
**    sp -- The sparse matrix from which the range value is to be        **
**          retrieved.                                                   **
**    dim -- The dimension of the minimum range value                    **
**                                                                       **
**  OUTPUT:                                                              **
**    int -- The minimum range value                                     **
**                                                                       **
**  SIDE EFFECTS:                                                        **
**    The error_no field of the sparse matrix can be set to an error if  **
**  an error is encountered.  Whenever an error is encountered, this     **
**  value is set and a NULL pointer is returned.  Thus, if a NULL        **
**  pointer is returned from this function it is important to examine    **
**  the error_no of the associated sparse matrix.                        **
**                                                                       **
**  NOTES:                                                               **
**                                                                       **
**************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include "sparse.h"

int sp_get_range_min(SPARSE_MATRIX *sp, int dim)
/* SPARSE_MATRIX *sp  The sparse matrix from which to retrieve the range 
                        value */
/* int dim            The dimension number */
{
  /* If the sparse matrix is empty, then a range value cannot be retrieved */
  if (sp == (SPARSE_MATRIX *)NULL)
  {
    return(0);
  }

  sp->error_no = SP_NOERR;

  /* Make sure that the dimension specified is legal */
  if ((sp->dimensions < dim) || (dim < (int)1))
  {
    sp->error_no = SP_DIM;
    return(0);
  }

  return(*(sp->hdr_ranges + ((dim - 1) * 2)));
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?