1 /*     CalculiX - A 3-dimensional finite element program                 */
2 /*              Copyright (C) 1998-2021 Guido Dhondt                          */
3 
4 /*     This program is free software; you can redistribute it and/or     */
5 /*     modify it under the terms of the GNU General Public License as    */
6 /*     published by the Free Software Foundation(version 2);    */
7 /*                                                                       */
8 
9 /*     This program is distributed in the hope that it will be useful,   */
10 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */
11 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
12 /*     GNU General Public License for more details.                      */
13 
14 /*     You should have received a copy of the GNU General Public License */
15 /*     along with this program; if not, write to the Free Software       */
16 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
17 
18 #include <stdlib.h>
19 #include <math.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include "CalculiX.h"
23 
insert_cmatrix(ITG * ipointer,ITG ** mast1p,ITG ** nextp,ITG * i1,ITG * i2,ITG * ifree,ITG * nzs_)24 void insert_cmatrix(ITG *ipointer, ITG **mast1p, ITG **nextp, ITG *i1,
25 		    ITG *i2, ITG *ifree, ITG *nzs_){
26 
27   /* routine for the lower triangular matrix, excluding the diagonal */
28 
29   /*   inserts a new nonzero matrix position into the data structure
30        in FORTRAN notation:
31        - ipointer(i) points to a position in field mast1 containing
32        the row number of a nonzero position in column i;
33        next(ipointer(i)) points a position in field mast1 containing
34        the row number of another nonzero position in column i, and
35        so on until no nonzero positions in column i are left; for
36        the position j in field mast1 containing the momentarily last
37        nonzero number in column i we have next(j)=0
38 
39        notice that in C the positions start at 0 and not at 1 as in
40        FORTRAN; the present routine is written in FORTRAN convention */
41 
42   ITG idof1,idof2,*mast1=NULL,*next=NULL;
43 
44   mast1=*mast1p;
45   next=*nextp;
46 
47   idof1=*i2;
48   idof2=*i1-1;
49 
50   if(*ifree>=*nzs_){
51     *nzs_=(ITG)(1.1**nzs_);
52     RENEW(mast1,ITG,*nzs_);
53     RENEW(next,ITG,*nzs_);
54   }
55   mast1[*ifree]=idof1;
56   next[*ifree]=ipointer[idof2];
57   ipointer[idof2]=++*ifree;
58 
59   *mast1p=mast1;
60   *nextp=next;
61 
62   return;
63 
64 }
65