⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vector_int.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 2 页
字号:
  if (vector != NULL)    for (component = 0; component < vector_dimension; component++)      if (vector[component] < min_value)        {          min_value = vector[component];          min_index = component;        }  if (winner != NULL)    *winner = min_index;  return(min_value);}int QccVectorIntPrint(const QccVectorInt vector,                      int vector_dimension){  int component;  if (vector == NULL)    return(0);  printf("< ");  for (component = 0; component < vector_dimension; component++)    printf("%d ", vector[component]);  printf(">\n");  return(0);}/*  Based on QS2I1D, part of the SLATEC library  */#define QccQuickSortSwap(a,b) {int temp;temp=(a);(a)=(b);(b)=temp;}static int QccVectorIntQuickSortAscending(QccVectorInt A,                                          int low,                                          int high){  int low_pnt, high_pnt, pivot_position;  int pivot;  pivot_position = low + (high - low)/2;  pivot = A[pivot_position];  /*  If first element of array is greater than it, interchange with it.  */  if (A[low] > pivot)    QccQuickSortSwap(A[pivot_position], A[low]);  /*  If last element of array is less than it, swap with it.  */  if (A[high] < pivot)    {      QccQuickSortSwap(A[pivot_position], A[high]);      /*  If first element of array is greater than it, swap with it.  */      if (A[low] > A[pivot_position])        QccQuickSortSwap(A[pivot_position], A[low]);    }    low_pnt = low;  high_pnt = high;  while (low_pnt < high_pnt)    {      /*  Find an element in the second half of the array which is          smaller than it.  */      do        high_pnt--;      while (A[high_pnt] > pivot);            /*  Find an element in the first half of the array which is          greater than it.  */      do        low_pnt++;      while (A[low_pnt] < pivot);            /*  Interchange these elements.  */      if (low_pnt <= high_pnt)        QccQuickSortSwap(A[high_pnt], A[low_pnt]);    }  if (high_pnt + 1 < high)    QccVectorIntQuickSortAscending(A, high_pnt + 1, high);  if (low < high_pnt)    QccVectorIntQuickSortAscending(A, low, high_pnt);  return(0);}static int QccVectorIntQuickSortAscendingWithAux(QccVectorInt A,                                                 int low,                                                  int high,                                                 int *auxiliary_list){  int low_pnt, high_pnt, pivot_position;  int pivot;  pivot_position = low + (high - low)/2;  pivot = A[pivot_position];  /*  If first element of array is greater than it, interchange with it.  */  if (A[low] > pivot)    {      QccQuickSortSwap(A[pivot_position], A[low]);      QccQuickSortSwap(auxiliary_list[pivot_position], auxiliary_list[low]);    }  /*  If last element of array is less than it, swap with it.  */  if (A[high] < pivot)    {      QccQuickSortSwap(A[pivot_position], A[high]);      QccQuickSortSwap(auxiliary_list[pivot_position], auxiliary_list[high]);      /*  If first element of array is greater than it, swap with it.  */      if (A[low] > A[pivot_position])        {          QccQuickSortSwap(A[pivot_position], A[low]);          QccQuickSortSwap(auxiliary_list[pivot_position],                           auxiliary_list[low]);        }    }    low_pnt = low;  high_pnt = high;  while (low_pnt < high_pnt)    {      /*  Find an element in the second half of the array which is          smaller than it.  */      do        high_pnt--;      while (A[high_pnt] > pivot);            /*  Find an element in the first half of the array which is          greater than it.  */      do        low_pnt++;      while (A[low_pnt] < pivot);            /*  Interchange these elements.  */      if (low_pnt <= high_pnt)        {          QccQuickSortSwap(A[high_pnt], A[low_pnt]);          QccQuickSortSwap(auxiliary_list[high_pnt], auxiliary_list[low_pnt]);        }    }  if (high_pnt + 1 < high)    QccVectorIntQuickSortAscendingWithAux(A, high_pnt + 1, high,                                          auxiliary_list);  if (low < high_pnt)    QccVectorIntQuickSortAscendingWithAux(A, low, high_pnt, auxiliary_list);  return(0);}int QccVectorIntSortComponents(const QccVectorInt vector,                               QccVectorInt sorted_vector,                               int vector_dimension,                               int sort_direction,                               int *auxiliary_list){  int component;  if ((vector == NULL) || (sorted_vector == NULL) ||      (vector_dimension <= 0))    return(0);  if (sort_direction == QCCVECTOR_SORTDESCENDING)    for (component = 0; component < vector_dimension; component++)      sorted_vector[component] = -vector[component];  else    for (component = 0; component < vector_dimension; component++)      sorted_vector[component] = vector[component];  if (auxiliary_list == NULL)    {      if (QccVectorIntQuickSortAscending(sorted_vector, 0,                                         vector_dimension - 1))        {          QccErrorAddMessage("(QccVectorIntSortComponents): Error calling QccVectorIntQuickSortAscending()");          return(1);        }    }  else    if (QccVectorIntQuickSortAscendingWithAux(sorted_vector, 0,                                               vector_dimension - 1,                                              auxiliary_list))      {        QccErrorAddMessage("(QccVectorIntSortComponents): Error calling QccVectorIntQuickSortAscendingWithIndex()");        return(1);      }  if (sort_direction == QCCVECTOR_SORTDESCENDING)    for (component = 0; component < vector_dimension; component++)      sorted_vector[component] = -sorted_vector[component];  return(0);}int QccVectorIntMoveComponentToFront(QccVectorInt vector,                                     int vector_dimension,                                     int index){  int component;  int tmp;  if (!index)    return(0);  if (index >= vector_dimension)    return(1);  tmp = vector[index];  for (component = index; component; component--)    vector[component] = vector[component - 1];  vector[0] = tmp;  return(0);}int QccVectorIntSubsample(const QccVectorInt input_signal,                          int input_length,                          QccVectorInt output_signal,                          int output_length,                          int sampling_flag){  int index;  if (input_signal == NULL)    return(0);  if (output_signal == NULL)    return(0);  switch (sampling_flag)    {    case QCCVECTOR_EVEN:      for (index = 0;           (index < output_length) && ((index * 2) < input_length);           index++)        output_signal[index] = input_signal[index * 2];      break;    case QCCVECTOR_ODD:      for (index = 0;           (index < output_length) && ((index * 2 + 1) < input_length);           index++)        output_signal[index] = input_signal[index * 2 + 1];      break;    default:      QccErrorAddMessage("(QccVectorIntSubsample): Undefined sampling (%d)",                         sampling_flag);      return(1);    }  return(0);}int QccVectorIntUpsample(const QccVectorInt input_signal,                         int input_length,                         QccVectorInt output_signal,                         int output_length,                         int sampling_flag){  int index;  if (input_signal == NULL)    return(0);  if (output_signal == NULL)    return(0);  QccVectorIntZero(output_signal, output_length);  switch (sampling_flag)    {    case QCCVECTOR_EVEN:      for (index = 0;           (index < input_length) && ((index * 2) < output_length);           index++)        output_signal[index * 2] = input_signal[index];      break;    case QCCVECTOR_ODD:      for (index = 0;           (index < input_length) && ((index * 2 + 1) < output_length);           index++)        output_signal[index * 2 + 1] = input_signal[index];      break;    default:      QccErrorAddMessage("(QccVectorIntUpsample): Undefined sampling (%d)",                         sampling_flag);      return(1);    }  return(0);}

⌨️ 快捷键说明

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