GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
setgmn.f
Go to the documentation of this file.
1 SUBROUTINE setgmn(meanv,covm,ldcovm,p,parm)
2C SUBROUTINE setgmn(meanv,covm,p,parm)
3C JJV changed this routine to take leading dimension of COVM
4C JJV argument and pass it to SPOTRF, making it easier to use
5C JJV if the COVM which is used is contained in a larger matrix
6C JJV and to make the routine more consistent with LAPACK.
7C JJV Changes are in comments, declarations, and the call to SPOTRF.
8C**********************************************************************
9C
10C SUBROUTINE SETGMN( MEANV, COVM, LDCOVM, P, PARM)
11C SET Generate Multivariate Normal random deviate
12C
13C
14C Function
15C
16C
17C Places P, MEANV, and the Cholesky factoriztion of COVM
18C in PARM for GENMN.
19C
20C
21C Arguments
22C
23C
24C MEANV --> Mean vector of multivariate normal distribution.
25C REAL MEANV(P)
26C
27C COVM <--> (Input) Covariance matrix of the multivariate
28C normal distribution. This routine uses only the
29C (1:P,1:P) slice of COVM, but needs to know LDCOVM.
30C
31C (Output) Destroyed on output
32C REAL COVM(LDCOVM,P)
33C
34C LDCOVM --> Leading actual dimension of COVM.
35C INTEGER LDCOVM
36C
37C P --> Dimension of the normal, or length of MEANV.
38C INTEGER P
39C
40C PARM <-- Array of parameters needed to generate multivariate
41C normal deviates (P, MEANV and Cholesky decomposition
42C of COVM).
43C 1 : 1 - P
44C 2 : P + 1 - MEANV
45C P+2 : P*(P+3)/2 + 1 - Cholesky decomposition of COVM
46C REAL PARM(P*(P+3)/2 + 1)
47C
48C**********************************************************************
49C .. Scalar Arguments ..
50C INTEGER p
51 INTEGER*4 p, ldcovm
52C ..
53C .. Array Arguments ..
54C REAL covm(p,p),meanv(p),parm(p* (p+3)/2+1)
55 REAL covm(ldcovm,p),meanv(p),parm(p* (p+3)/2+1)
56C ..
57C .. Local Scalars ..
58 INTEGER*4 i,icount,info,j
59C ..
60C .. External Subroutines ..
61 EXTERNAL spotrf
62C ..
63C .. Executable Statements ..
64C
65C
66C TEST THE INPUT
67C
68 IF (.NOT. (p.LE.0)) GO TO 10
69 WRITE (*,*) 'P nonpositive in SETGMN'
70 WRITE (*,*) 'Value of P: ',p
71 CALL xstopx ('P nonpositive in SETGMN')
72
73 10 parm(1) = p
74C
75C PUT P AND MEANV INTO PARM
76C
77 DO 20,i = 2,p + 1
78 parm(i) = meanv(i-1)
79 20 CONTINUE
80C
81C Cholesky decomposition to find A s.t. trans(A)*(A) = COVM
82C
83C CALL spofa(covm,p,p,info)
84C CALL spofa(covm,ldcovm,p,info)
85 CALL spotrf ( 'Upper', p, covm, ldcovm, info)
86 IF (.NOT. (info.NE.0)) GO TO 30
87 WRITE (*,*) ' COVM not positive definite in SETGMN'
88 CALL xstopx (' COVM not positive definite in SETGMN')
89
90 30 icount = p + 1
91C
92C PUT UPPER HALF OF A, WHICH IS NOW THE CHOLESKY FACTOR, INTO PARM
93C COVM(1,1) = PARM(P+2)
94C COVM(1,2) = PARM(P+3)
95C :
96C COVM(1,P) = PARM(2P+1)
97C COVM(2,2) = PARM(2P+2) ...
98C
99 DO 50,i = 1,p
100 DO 40,j = i,p
101 icount = icount + 1
102 parm(icount) = covm(i,j)
103 40 CONTINUE
104 50 CONTINUE
105 RETURN
106C
107 END
subroutine setgmn(meanv, covm, ldcovm, p, parm)
Definition setgmn.f:2