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

📄 vector.c

📁 有限元分析源代码
💻 C
字号:
/* *  =============================================================================  *  ALADDIN Version 1.0 : *             vector.c : Functions for Vector Operations and Printing *                                                                      *  Copyright (C) 1995 by Mark Austin, Xiaoguang Chen, and Wane-Jang Lin *  Institute for Systems Research,                                            *  University of Maryland, College Park, MD 20742                                    *                                                                      *  This software is provided "as is" without express or implied warranty. *  Permission is granted to use this software for any on any computer system *  and to redistribute it freely, subject to the following restrictions: *  *  1. The authors are not responsible for the consequences of use of *     this software, even if they arise from defects in the software. *  2. The origin of this software must not be misrepresented, either *     by explicit claim or by omission. *  3. Altered versions must be plainly marked as such, and must not *     be misrepresented as being the original software. *  4. This notice is to remain intact. *                                                                     *  Written by: M.A. Austin                                             July 1992 *  =============================================================================  */#include <stdio.h>#include "units.h"#include "matrix.h"#include "vector.h"#include "miscellaneous.h"#include "defs.h"/* #define DEBUG *//* *  ================================================================= *  Print a Vector [length] *   *  where --  length = number of items in vector. *  ================================================================= */#ifdef __STDC__void VectorPrint(VECTOR *v)#elsevoid VectorPrint(v)VECTOR *v;#endif{       switch((int) v->eType) {              case INTEGER_ARRAY:                   (void) PrintVectorInteger(v);                   break;              case DOUBLE_ARRAY:                   (void) PrintVectorDouble(v);                   break;              default:                   FatalError("In VectorPrint() : Undefined v->eType",(char *)NULL);                   break;       }}/* *  ================================================= *  Allocate Vector data structure, and array[length] *  ================================================= */#ifdef __STDC__VECTOR *VectorAlloc(char *name, DATA_TYPE type, int length)#elseVECTOR *VectorAlloc(name, type, length)char       *name;DATA_TYPE   type;int       length;#endif{VECTOR *v;int     i;   /* Allocate matrix parent data structure, and name */      v = (VECTOR *) MyMalloc(sizeof(VECTOR));      if(name != NULL)         v->cpVectorName = SaveString(name);      else          v->cpVectorName = (char *) NULL;   /* Set parameters and allocate memory for matrix array */      v->eType       = type;      v->iLength    = length;      switch((int) v->eType) {          case INTEGER_ARRAY:               v->uVector.ia = iVectorAlloc(length);               break;          case DOUBLE_ARRAY:               v->uVector.da = dVectorAlloc(length);               break;          default:               break;      }      return (v);}#ifdef __STDC__void VectorFree(VECTOR *v)#elsevoid VectorFree(v)VECTOR *v;#endif{      switch((int) v->eType) {          case INTEGER_ARRAY:               VectorFreeInteger(v);               break;          case DOUBLE_ARRAY:               VectorFreeDouble(v);               break;          default:               FatalError("In VectorFree() : Undefined v->eType",(char *)NULL);               break;      }}/* *  ================= *  Vector Operations *  ================= */#ifdef __STDC__VECTOR *VectorAdd(VECTOR *v1, VECTOR *v2)#elseVECTOR *VectorAdd(v1, v2)VECTOR *v1;VECTOR *v2;#endif{int i,j;    switch((int) v1->eType) {        case INTEGER_ARRAY:             v1 = VectorAddInteger(v1, v2);             break;        case DOUBLE_ARRAY:             v1 = VectorAddDouble(v1, v2);             break;        default:             FatalError("In VectorAdd() : Undefined v->eType",(char *)NULL);             break;    }    return (v1);}#ifdef __STDC__VECTOR *VectorSub(VECTOR *v1, VECTOR *v2)#elseVECTOR *VectorSub(v1, v2)VECTOR *v1;VECTOR *v2;#endif{    switch((int) v1->eType) {        case INTEGER_ARRAY:             v1 = VectorSubInteger(v1, v2);             break;        case DOUBLE_ARRAY:             v1 = VectorSubDouble(v1, v2);             break;        default:             FatalError("In VectorSub() : Undefined v->eType",(char *)NULL);             break;    }    return (v1);}

⌨️ 快捷键说明

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