1 /* mxvg.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure      MXVG ( Matrix time vector, general dimension ) */
mxvg_(doublereal * m1,doublereal * v2,integer * nr1,integer * nc1r2,doublereal * vout)9 /* Subroutine */ int mxvg_(doublereal *m1, doublereal *v2, integer *nr1,
10 	integer *nc1r2, doublereal *vout)
11 {
12     /* System generated locals */
13     integer m1_dim1, m1_dim2, m1_offset, v2_dim1, vout_dim1, i__1, i__2, i__3,
14 	     i__4;
15 
16     /* Builtin functions */
17     integer s_rnge(char *, integer, char *, integer);
18 
19     /* Local variables */
20     integer i__, k;
21     doublereal sum;
22 
23 /* $ Abstract */
24 
25 /*     Multiply a matrix and a vector of arbitrary size. */
26 
27 /* $ Disclaimer */
28 
29 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
30 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
31 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
32 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
33 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
34 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
35 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
36 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
37 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
38 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
39 
40 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
41 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
42 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
43 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
44 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
45 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
46 
47 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
48 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
49 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
50 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
51 
52 /* $ Required_Reading */
53 
54 /*     None. */
55 
56 /* $ Keywords */
57 
58 /*     MATRIX */
59 /*     VECTOR */
60 
61 /* $ Declarations */
62 /* $ Brief_I/O */
63 
64 /*     VARIABLE  I/O  DESCRIPTION */
65 /*     --------  ---  -------------------------------------------------- */
66 /*     M1         I   Left-hand matrix to be multiplied. */
67 /*     V2         I   Right-hand vector to be multiplied. */
68 /*     NR1        I   Row dimension of M1 and length of VOUT. */
69 /*     NC1R2      I   Column dimension of M1 and length of V2. */
70 /*     VOUT       O   Product vector M1*V2. */
71 
72 /* $ Detailed_Input */
73 
74 /*     M1      This is a double precision matrix of arbitrary size which */
75 /*             forms the left-hand matrix of the multiplication. */
76 
77 /*     V2      This is a double precision vector on the right of the */
78 /*             multiplication. */
79 
80 /*     NR1     This is the row dimension of M1 and length of VOUT. */
81 
82 /*     NC1R2   This is the column dimension of M1 and length of V2. */
83 
84 /* $ Detailed_Output */
85 
86 /*     VOUT    This is the double precision vector which results from */
87 /*             the expression VOUT = (M1) x V2. */
88 
89 /* $ Parameters */
90 
91 /*     None. */
92 
93 /* $ Exceptions */
94 
95 /*     Error free. */
96 
97 /* $ Files */
98 
99 /*     None. */
100 
101 /* $ Particulars */
102 
103 /*     The code reflects precisely the following mathematical expression */
104 
105 /*        For each value of the subscript I from 1 to NR1, */
106 
107 /*        VOUT(I) = Summation from K=1 to NC1R2 of  ( M1(I,K) * V2(K) ) */
108 
109 /* $ Examples */
110 
111 /*     Suppose that M1  = | 1  1  1 | */
112 /*                        | 2  3  4 | */
113 
114 /*                        | 1 | */
115 /*     and that     V2  = | 2 | */
116 /*                        | 3 | */
117 
118 /*     Then calling MXVG according to the following calling sequence */
119 
120 /*        CALL MXVG (M1, V2, 2, 3, VOUT) */
121 
122 /*     will yield the following vector value for VOUT */
123 
124 /*        VOUT = | 6  | */
125 /*               | 20 | */
126 
127 /* $ Restrictions */
128 
129 /*     1) The user is responsible for checking the magnitudes of the */
130 /*        elements of M1 and V2 so that a floating point overflow does */
131 /*        not occur. */
132 
133 /* $ Literature_References */
134 
135 /*     None. */
136 
137 /* $ Author_and_Institution */
138 
139 /*     W.M. Owen       (JPL) */
140 
141 /* $ Version */
142 
143 /* -    SPICELIB Version 1.0.2, 23-APR-2010 (NJB) */
144 
145 /*        Re-ordered header sections and made minor formatting */
146 /*        changes. */
147 
148 /* -    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
149 
150 /*        Comment section for permuted index source lines was added */
151 /*        following the header. */
152 
153 /* -    SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) */
154 
155 /* -& */
156 /* $ Index_Entries */
157 
158 /*     matrix times n-dimensional vector */
159 
160 /* -& */
161 
162 /*  Perform the matrix-vector multiplication */
163 
164     /* Parameter adjustments */
165     vout_dim1 = *nr1;
166     v2_dim1 = *nc1r2;
167     m1_dim1 = *nr1;
168     m1_dim2 = *nc1r2;
169     m1_offset = m1_dim1 + 1;
170 
171     /* Function Body */
172     i__1 = *nr1;
173     for (i__ = 1; i__ <= i__1; ++i__) {
174 	sum = 0.;
175 	i__2 = *nc1r2;
176 	for (k = 1; k <= i__2; ++k) {
177 	    sum += m1[(i__3 = i__ + k * m1_dim1 - m1_offset) < m1_dim1 *
178 		    m1_dim2 && 0 <= i__3 ? i__3 : s_rnge("m1", i__3, "mxvg_",
179 		    (ftnlen)163)] * v2[(i__4 = k - 1) < v2_dim1 && 0 <= i__4 ?
180 		     i__4 : s_rnge("v2", i__4, "mxvg_", (ftnlen)163)];
181 	}
182 	vout[(i__2 = i__ - 1) < vout_dim1 && 0 <= i__2 ? i__2 : s_rnge("vout",
183 		 i__2, "mxvg_", (ftnlen)165)] = sum;
184     }
185     return 0;
186 } /* mxvg_ */
187 
188