MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
test.c
Go to the documentation of this file.
1 /*
2  * This library comes with MBDyn (C), a multibody analysis code.
3  * http://www.mbdyn.org
4  *
5  * Copyright (C) 1996-2017
6  *
7  * Pierangelo Masarati <masarati@aero.polimi.it>
8  *
9  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
10  * via La Masa, 34 - 20156 Milano, Italy
11  * http://www.aero.polimi.it
12  *
13  * Changing this copyright notice is forbidden.
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation (version 2 of the License).
18  *
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28  */
29 
30 #include "mbconfig.h"
31 
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include "ac/f2c.h"
35 
36 #include "y12lib.h"
37 
38 #ifdef USE_Y12
39 
40 int
41 main(void)
42 {
43  const integer N = 2; /* size */
44  const integer Z = 3; /* non-zeroes */
45 
46  const integer NN = 3*Z; /* size of A and SNR */
47  doublereal A[9]; /* matrix NN = 3*Z */
48  integer SNR[9]; /* column indices NN = 3*Z */
49 
50  const integer NN1 = 3*Z;/* size of RNR */
51  integer RNR[9]; /* row indices NN1 = 3*Z */
52 
53  const integer IHA = N; /* size of HA */
54  integer HA[22]; /* work array IHA*11 */
55 
56  doublereal AFLAG[8]; /* ? */
57  integer IFLAG[10]; /* ? */
58 
59  integer IFAIL = 0; /* diagnostics */
60 
61  doublereal PIVOT[2]; /* pivot factors N */
62  doublereal B[2]; /* RHS of problem N */
63 
64  A[0] = 2.; /* 1, 1 */
65  A[1] = 1.; /* 2, 1 */
66  A[2] = 1.; /* 2, 2 */
67 
68  SNR[0] = 1;
69  SNR[1] = 1;
70  SNR[2] = 2;
71 
72  RNR[0] = 1;
73  RNR[1] = 2;
74  RNR[2] = 2;
75 
76  IFLAG[0] = 0;
77  IFLAG[1] = 3;
78  IFLAG[2] = 1; /* total pivoting */
79  IFLAG[3] = 0;
80  IFLAG[4] = 2;
81 
82  __FC_DECL__(y12mbf)((integer *)&N, (integer *)&Z, A, SNR,
83  (integer *)&NN, RNR,
84  (integer *)&NN1, HA, (integer *)&IHA, AFLAG, IFLAG,
85  &IFAIL);
86 
87 
88  B[0] = 1.;
89  B[1] = 1.;
90 
91  __FC_DECL__(y12mcf)((integer *)&N, (integer *)&Z, A, SNR,
92  (integer *)&NN, RNR,
93  (integer *)&NN1, PIVOT, B, HA, (integer *)&IHA, AFLAG,
94  IFLAG, &IFAIL);
95 
96  __FC_DECL__(y12mdf)((integer *)&N, A, (integer *)&NN, B, PIVOT, SNR,
97  HA,
98  (integer *)&IHA, IFLAG, &IFAIL);
99 
100  fprintf(stdout, "B = {%e,%e}\n", B[0], B[1]);
101 
102  IFLAG[4] = 3;
103 
104  B[0] = 2.;
105  B[1] = 2.;
106 
107  __FC_DECL__(y12mdf)((integer *)&N, A, (integer *)&NN, B, PIVOT, SNR,
108  HA,
109  (integer *)&IHA, IFLAG, &IFAIL);
110 
111  fprintf(stdout, "B = {%e,%e}\n", B[0], B[1]);
112 
113  B[0] = 2.;
114  B[1] = -1.;
115 
116  __FC_DECL__(y12mdf)((integer *)&N, A, (integer *)&NN, B, PIVOT, SNR,
117  HA,
118  (integer *)&IHA, IFLAG, &IFAIL);
119 
120  fprintf(stdout, "B = {%e,%e}\n", B[0], B[1]);
121 
122  return 0;
123 }
124 
125 #else /* ! USE_Y12 */
126 
127 int
128 main(void)
129 {
130  printf("configure --with-y12 to enable Y12\n");
131 
132  return 0;
133 }
134 
135 #endif /* ! USE_Y12 */
int __FC_DECL__() y12mdf(integer *n, doublereal *const a, integer *nn, doublereal *const b, doublereal *pivot, integer *const snr, integer *ha, integer *iha, integer *iflag, integer *ifail)
int main(void)
Definition: test.c:128
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
int __FC_DECL__() y12mbf(integer *n, integer *z__, doublereal *const a, integer *const snr, integer *nn, integer *const rnr, integer *nn1, integer *ha, integer *iha, doublereal *aflag, integer *iflag, integer *ifail)
int __FC_DECL__() y12mcf(integer *n, integer *z__, doublereal *const a, integer *const snr, integer *nn, integer *const rnr, integer *nn1, doublereal *pivot, doublereal *const b, integer *ha, integer *iha, doublereal *aflag, integer *iflag, integer *ifail)