SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
RandUnuran.java
1/*
2 * Class: RandUnuran
3 * Description: provides the access point to the C package UNURAN
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author Éric Buist
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.randvar;
26
27import umontreal.ssj.rng.*;
28import umontreal.ssj.util.NativeUtils;
29
37class RandUnuran {
38
39 // These arrays are used to store precomputed uniforms
40 // from main and auxiliary streams when generating
41 // arrays of variates.
42 protected double[] unifArray = null;
43 protected double[] unifAuxArray = null;
44
45 protected RandomStream mainStream;
46 protected RandomStream auxStream;
47 protected long nativeParams = 0;
48
49 protected RandUnuran() {
50 }
51
52 protected native void init(String genStr);
53
54 protected void finalize() {
55 close();
56 }
57
58 public native void close();
59
60 // random variate generation native methods
61 protected native int getRandDisc(double u, long np);
62
63 protected native double getRandCont(double u, long np);
64
65 protected native void getRandVec(double u, long np, double[] vec);
66
67 // random array of variates generation native methods
68 protected native void getRandDiscArray(long np, double[] u, double[] uaux, int[] v, int start, int n);
69
70 protected native void getRandContArray(long np, double[] u, double[] uaux, double[] v, int start, int n);
71
72 // methods to query the type of distribution for error checking
73 protected native boolean isDiscrete();
74
75 protected native boolean isContinuous();
76
77 protected native boolean isContinuousMultivariate();
78
79 protected native boolean isEmpirical();
80
81 protected native boolean isEmpiricalMultivariate();
82
83 static {
84 try {
85 NativeUtils.loadLibraryFromJar("/jni/" + System.mapLibraryName("randvar"));
86 } catch (java.io.IOException e) {
87 throw new UnsatisfiedLinkError(e.getMessage());
88 }
89 }
90}
A simple library class which helps with loading dynamic libraries stored in the JAR archive.
static void loadLibraryFromJar(String path)
Loads library from current JAR archive.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...