View Javadoc
1   /*
2    * Copyright 2009 Ange Optimization ApS
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package eu.simuline.octave.type;
17  
18  /**
19   * Place holder for factory methods. 
20   */
21  public final class Octave {
22  
23      /**
24       * Constant true of corresponding with octave bool. 
25       */
26      private final static OctaveBoolean TRUE = 
27  	new OctaveBoolean(new boolean[] {true}, 1, 1);
28  
29      /**
30       * Constant false of corresponding with octave bool. 
31       */
32      private final static OctaveBoolean FALSE = 
33  	new OctaveBoolean(new boolean[] {false}, 1, 1);
34  
35      private Octave() {
36          throw new UnsupportedOperationException("Do not instantiate");
37      }
38  
39      /**
40       * Returns java counterparts of octave scalars. 
41       *
42       * @param d
43       * @return New OctaveDouble with a single value
44       */
45      // used by user and in tests only 
46      public static OctaveDouble scalar(final double d) {
47          return new OctaveDouble(new double[] {d}, 1, 1);
48      }
49  
50      /**
51       * Returns java counterparts of octave bools. 
52       *
53       * @param b
54       * @return New OctaveBoolean with a single value
55       */
56      // used by user only 
57      public static OctaveBoolean bool(final boolean b) {
58          return b ? TRUE : FALSE;
59      }
60  
61  }