Revision 210

tmp/org.txm.r.core/.project (revision 210)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.r</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.r.core/src/org/txm/stat/package.html (revision 210)
1
<html>
2
<body>
3
<p>Root package of all statistical and numeric computing functions of the toolbox.</p>
4
</body>
5
</html>
0 6

  
tmp/org.txm.r.core/src/org/txm/stat/utils/PrintArray.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.stat.utils;
29

  
30
import java.util.Arrays;
31

  
32
// TODO: Auto-generated Javadoc
33
/**
34
 * Various utilities method for printing arrays.
35
 * 
36
 * @author sloiseau
37
 * 
38
 */
39
public final class PrintArray {
40

  
41
	/**
42
	 * Double array.
43
	 *
44
	 * @param matrix the matrix
45
	 * @return the string
46
	 */
47
	public final static String doubleArray(double[][] matrix) {
48
		// DoubleMatrix2D m = new SparseDoubleMatrix2D(matrix);
49
		// return m.toString();
50
		StringBuffer sb = new StringBuffer();
51
		for (int i = 0; i < matrix.length; i++) {
52
			sb.append(Arrays.toString(matrix[i]));
53
		}
54
		return sb.toString();
55
	}
56

  
57
	/**
58
	 * Int array.
59
	 *
60
	 * @param matrix the matrix
61
	 * @return the string
62
	 */
63
	public final static String intArray(int[][] matrix) {
64
		double[][] doublematrix = new double[matrix.length][matrix[0].length];
65
		for (int i = 0; i < matrix.length; i++) {
66
			for (int j = 0; j < doublematrix[i].length; j++) {
67
				doublematrix[i][j] = matrix[i][j];
68
			}
69
		}
70
		return doubleArray(doublematrix);
71
	}
72

  
73
}
0 74

  
tmp/org.txm.r.core/src/org/txm/stat/utils/CheckArray.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.stat.utils;
29

  
30
// TODO: Auto-generated Javadoc
31
/**
32
 * Various utility methods for checking consistency of matrix as java array of
33
 * arrays.
34
 * 
35
 * @author sloiseau
36
 * 
37
 */
38
public final class CheckArray {
39

  
40
	/**
41
	 * Check if an array is not null (or 0-length), does not include null inner
42
	 * array (or 0 length), and if all inner arrays have the same length.
43
	 *
44
	 * @param array the array
45
	 * @return <code>true</code> if the condition are satisfied,
46
	 * <code>false</code> otherwise.
47
	 */
48
	public final static boolean checkMatrixRepresentation(int[][] array) {
49
		// same code as in #checkMatrixRepresentation(double[][])
50
		if (array == null)
51
			return false;
52
		int length = array.length;
53
		if (length < 1)
54
			return false;
55
		if (array[0] == null)
56
			return false;
57
		int firstElementLength = array[0].length;
58
		if (firstElementLength == 0)
59
			return false;
60
		for (int i = 0; i < array.length; i++) {
61
			if (array[i] == null)
62
				return false;
63
			if (array[i].length != firstElementLength)
64
				return false;
65
		}
66
		return true;
67
	}
68

  
69
	/**
70
	 * Check if an array is not null (or 0-length), does not include null inner
71
	 * array (or 0 length), and if all inner arrays have the same length.
72
	 *
73
	 * @param array the array
74
	 * @return <code>true</code> if the condition are satisfied,
75
	 * <code>false</code> otherwise.
76
	 */
77
	public final static boolean checkMatrixRepresentation(double[][] array) {
78
		// same code as in #checkMatrixRepresentation(int[][])
79
		if (array == null)
80
			return false;
81
		int length = array.length;
82
		if (length < 1)
83
			return false;
84
		if (array[0] == null)
85
			return false;
86
		int firstElementLength = array[0].length;
87
		if (firstElementLength == 0)
88
			return false;
89
		for (int i = 0; i < array.length; i++) {
90
			if (array[i] == null)
91
				return false;
92
			if (array[i].length != firstElementLength)
93
				return false;
94
		}
95
		return true;
96
	}
97

  
98
}
0 99

  
tmp/org.txm.r.core/src/org/txm/stat/utils/package.html (revision 210)
1
<html>
2
<body>
3
<p>Utility functions for dealing with array (vectorizing, indexing, checking consistency...).</p>
4
</body>
5
</html>
0 6

  
tmp/org.txm.r.core/src/org/txm/stat/utils/ArrayIndex.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.stat.utils;
29

  
30
import java.util.HashMap;
31
import java.util.Map;
32

  
33
import org.txm.Messages;
34

  
35
// TODO: Auto-generated Javadoc
36
/**
37
 * Utilities for managing index of vector.
38
 * 
39
 * @author sloiseau
40
 * 
41
 */
42
public final class ArrayIndex {
43

  
44
	/**
45
	 * Convert an array of zero-based index to an array of one-base index, that
46
	 * is, add <code>1</code> to all elements.
47
	 * 
48
	 * This method check every index (see exception thrown).
49
	 *
50
	 * @param zero_based the zero based index.
51
	 * @param length the number of elements that can be indexed.
52
	 * @return the one base index.
53
	 */
54
	public static final int[] zeroToOneBasedIndex(int[] zero_based, int length) {
55
		if (zero_based == null || zero_based.length == 0) {
56
			throw new IllegalArgumentException(Messages.ArrayIndex_0);
57
		}
58
		int[] one_based = new int[zero_based.length];
59
		for (int i = 0; i < zero_based.length; i++) {
60
			if (zero_based[i] < 0 || zero_based[i] >= length) {
61
				throw new IllegalArgumentException(Messages.ArrayIndex_1);
62
			}
63
			one_based[i] = zero_based[i] + 1;
64
		}
65
		return one_based;
66
	}
67

  
68
	/**
69
	 * Zero to one based index.
70
	 *
71
	 * @param zero_based the zero_based
72
	 * @return the int
73
	 */
74
	public static final int zeroToOneBasedIndex(int zero_based) {
75
		return zero_based + 1;
76
	}
77

  
78
	/**
79
	 * Get the index (0-based) of the element of subvector into vector. Return
80
	 * <code>-1</code> when no element in vector correspond to the element in
81
	 * subvector.
82
	 *
83
	 * @param vector the vector
84
	 * @param subvector the subvector
85
	 * @return the index
86
	 */
87
	public static int[] getIndex(String[] vector, String[] subvector) {
88
		int[] result = new int[subvector.length];
89
		Map<String, Integer> index = new HashMap<String, Integer>();
90
		for (int i = 0; i < subvector.length; i++) {
91
			index.put(subvector[i], i);
92
			result[i] = -1;
93
		}
94
		for (int i = 0; i < vector.length; i++) {
95
			if (index.containsKey(vector[i])) {
96
				result[index.get(vector[i])] = i;
97
			}
98
		}
99
		return result;
100
	}
101
}
0 102

  
tmp/org.txm.r.core/src/org/txm/stat/utils/ArrayEquals.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.stat.utils;
29

  
30
import java.util.Arrays;
31

  
32
// TODO: Auto-generated Javadoc
33
/**
34
 * Utility methods for testing for equality of arrays.
35
 * 
36
 * @author sloiseau
37
 * 
38
 */
39
public final class ArrayEquals {
40

  
41
	/**
42
	 * Test for equality of both array. For consistency with Arrays.equals
43
	 * contract, the two arrays are equals if both are <code>null</code>.
44
	 *
45
	 * @param array1 the array1
46
	 * @param array2 the array2
47
	 * @return <code>true</code> if (1) both arrays are <code>null</code> or if
48
	 * (2) both arrays have the same length and contain pair of arrays
49
	 * equals to each other according to
50
	 * {@link Arrays#equals(int[], int[])}.
51
	 */
52
	public static final boolean deepEquals(int[][] array1, int[][] array2) {
53
		if (array1 == null && array2 == null)
54
			return true;
55
		if (array1 == null || array2 == null)
56
			return false;
57
		if (array1.length != array2.length)
58
			return false;
59
		for (int i = 0; i < array2.length; i++) {
60
			if (!Arrays.equals(array1[i], array2[i]))
61
				return false;
62
		}
63
		return true;
64
	}
65

  
66
}
0 67

  
tmp/org.txm.r.core/src/org/txm/stat/utils/VectorizeArray.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.stat.utils;
29

  
30
import org.txm.Messages;
31

  
32
// TODO: Auto-generated Javadoc
33
/**
34
 * Static methods for dealing vectorization of Arrays.
35
 * 
36
 * @author sloiseau
37
 * 
38
 */
39
public final class VectorizeArray {
40

  
41
	/**
42
	 * Convert a <code>double * double</code> array in a <code>double</code>
43
	 * array. Each inner array of the argument is added one after the other into
44
	 * the result array.
45
	 * 
46
	 * <pre>
47
	 * [
48
	 * [1, 2, 3],
49
	 * [4, 5, 6]
50
	 * ]
51
	 * </pre>
52
	 * 
53
	 * result in :
54
	 * 
55
	 * <pre>
56
	 * [1, 2, 3, 4, 5, 6]
57
	 * </pre>
58
	 * 
59
	 * that is, "row first".
60
	 *
61
	 * @param matrix a <code>double * double</code> array where all inner arrays
62
	 * have the same length.
63
	 * @return an array of <code>double</code> produced by vectorization of the
64
	 * matrix.
65
	 */
66
	public final static double[] vectorizeByInner(double[][] matrix) {
67
		if (matrix == null || matrix.length == 0) {
68
			throw new IllegalArgumentException(Messages.VectorizeArray_0);
69
		}
70
		int inner_length = matrix[0].length;
71
		if (inner_length < 1) {
72
			throw new IllegalArgumentException(Messages.VectorizeArray_1);
73
		}
74
		double[] vector = new double[matrix.length * matrix[0].length];
75
		for (int i = 0; i < matrix.length; i++) {
76
			if (matrix[i] == null) {
77
				throw new IllegalArgumentException(Messages.VectorizeArray_10);
78
			}
79
			if (inner_length != matrix[i].length) {
80
				throw new IllegalArgumentException(Messages.VectorizeArray_3);
81
			}
82
			System.arraycopy(matrix[i], 0, vector, i * inner_length,
83
					inner_length);
84
		}
85
		return vector;
86
	}
87

  
88
	/**
89
	 * Convert a <code>int * int</code> array in a <code>double</code> array.
90
	 * Each inner array of the argument is added one after the other into the
91
	 * result array.
92
	 * 
93
	 * <pre>
94
	 * [
95
	 * [1, 2, 3],
96
	 * [4, 5, 6]
97
	 * ]
98
	 * </pre>
99
	 * 
100
	 * result in :
101
	 * 
102
	 * <pre>
103
	 * [1, 2, 3, 4, 5, 6]
104
	 * </pre>
105
	 * 
106
	 * that is, "row first".
107
	 *
108
	 * @param matrix a <code>int * int</code> array where all inner arrays have the
109
	 * same length.
110
	 * @return an array of <code>int</code> produced by vectorization of the
111
	 * matrix.
112
	 */
113
	public final static int[] vectorizeByInner(int[][] matrix) {
114
		if (matrix == null || matrix.length == 0) {
115
			throw new IllegalArgumentException(Messages.VectorizeArray_4);
116
		}
117
		int inner_length = matrix[0].length;
118
		if (inner_length < 1) {
119
			throw new IllegalArgumentException(Messages.VectorizeArray_5);
120
		}
121
		int[] vector = new int[matrix.length * matrix[0].length];
122
		for (int i = 0; i < matrix.length; i++) {
123
			if (matrix[i] == null) {
124
				throw new IllegalArgumentException(Messages.VectorizeArray_10);
125
			}
126
			if (inner_length != matrix[i].length) {
127
				throw new IllegalArgumentException(Messages.VectorizeArray_7);
128
			}
129
			System.arraycopy(matrix[i], 0, vector, i * inner_length,
130
					inner_length);
131
		}
132
		return vector;
133
	}
134

  
135
	/**
136
	 * Convert a <code>double * double</code> array in a <code>double</code>
137
	 * array. The elements of the input array are assembled in the output array
138
	 * so that elements of same index in the outer array are consecutive. So :
139
	 * 
140
	 * <pre>
141
	 * [
142
	 * [1, 2, 3],
143
	 * [4, 5, 6]
144
	 * ]
145
	 * </pre>
146
	 * 
147
	 * result in :
148
	 * 
149
	 * <pre>
150
	 * [1, 4, 2, 5, 3, 6]
151
	 * </pre>
152
	 * 
153
	 * that is, "column first".
154
	 *
155
	 * @param matrix a <code>double * double</code> array where all inner arrays
156
	 * have the same length.
157
	 * @return an array of <code>double</code> produced by vectorization of the
158
	 * matrix.
159
	 */
160
	public final static double[] vectorizeByOuter(double[][] matrix) {
161
		if (matrix == null || matrix.length == 0) {
162
			throw new IllegalArgumentException(Messages.VectorizeArray_8);
163
		}
164
		int inner_length = matrix[0].length;
165
		int outer_length = matrix.length;
166
		if (inner_length < 1) {
167
			throw new IllegalArgumentException(Messages.VectorizeArray_9);
168
		}
169
		double[] vector = new double[matrix.length * matrix[0].length];
170
		for (int i = 0; i < matrix.length; i++) {
171
			if (matrix[i] == null) {
172
				throw new IllegalArgumentException(Messages.VectorizeArray_10);
173
			}
174
			if (inner_length != matrix[i].length) {
175
				throw new IllegalArgumentException(Messages.VectorizeArray_11);
176
			}
177
			for (int j = 0; j < matrix[i].length; j++) {
178
				vector[(j * outer_length) + i] = matrix[i][j];
179
			}
180

  
181
		}
182
		return vector;
183
	}
184

  
185
}
0 186

  
tmp/org.txm.r.core/src/org/txm/stat/ConnectToRserve.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.stat;
29
import org.rosuda.REngine.REXP;
30
import org.rosuda.REngine.RList;
31
import org.rosuda.REngine.Rserve.RConnection;
32

  
33
// TODO: Auto-generated Javadoc
34
/**
35
 * The Class ConnectToRserve.
36
 */
37
class ConnectToRserve {
38
	
39
	/**
40
	 * The main method.
41
	 *
42
	 * @param args the arguments
43
	 */
44
	public static void main(String args[]) {
45
		try {
46
			RConnection c = new RConnection();
47
			String userhome = System.getProperty("user.home"); //$NON-NLS-1$
48
			RList ret = c.eval("source('"+userhome+"/Bureau/R/Rdata')").asList(); //$NON-NLS-1$ //$NON-NLS-2$
49
			
50
			System.out.println("source ret : "+ret.get(1)); //$NON-NLS-1$
51
			System.out.println(ret);
52
			
53
			REXP ret2 = c.eval("print(lexicaltable)"); //$NON-NLS-1$
54
			System.out.println("lexicaltable :"+ret2); //$NON-NLS-1$
55
		}
56
		catch(Exception e) {
57
			org.txm.utils.logger.Log.printStackTrace(e);
58
		}
59
	}
60
}
0 61

  
tmp/org.txm.r.core/src/org/txm/stat/engine/r/RFileCommunication.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2015-05-22 09:06:15 +0200 (Fri, 22 May 2015) $
25
// $LastChangedRevision: 2973 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.stat.engine.r;
29

  
30
import java.io.BufferedWriter;
31
import java.io.File;
32
import java.io.FileWriter;
33
import java.io.IOException;
34

  
35
import org.eclipse.core.runtime.Platform;
36
import org.txm.utils.OSDetector;
37

  
38

  
39
// TODO: Auto-generated Javadoc
40
/**
41
 * The Class RFileCommunication.
42
 */
43
public class RFileCommunication {
44
	
45
	/** The transfertfile. */
46
	File transfertfile;
47
	
48
	/** The transfertfilepath. */
49
	String transfertfilepath;
50

  
51
	/**
52
	 * Instantiates a new r file communication.
53
	 *
54
	 * @throws IOException Signals that an I/O exception has occurred.
55
	 */
56
	public RFileCommunication() throws IOException
57
	{
58
		createTempFile();
59

  
60
	}
61

  
62
	/**
63
	 * Creates the temp file.
64
	 *
65
	 * @throws IOException Signals that an I/O exception has occurred.
66
	 */
67
	public void createTempFile() throws IOException
68
	{
69
		transfertfile = File.createTempFile("Rtransfert","file"); //$NON-NLS-1$ //$NON-NLS-2$
70
		//transfertfile = new File("~/Bureau/RTRANSFERT.txt");
71
		transfertfilepath = transfertfile.getAbsolutePath();
72
		if (OSDetector.isFamilyWindows()) //$NON-NLS-1$ //$NON-NLS-2$
73
		{
74
			//System.out.println("patch path");
75
			transfertfilepath = transfertfilepath.replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
76
		}
77
		//System.out.println("Transfert file: "+transfertfilepath);
78
	}
79

  
80
	/**
81
	 * Assign.
82
	 *
83
	 * @param variablename the variablename
84
	 * @param matrix the matrix
85
	 * @param nrow the nrow
86
	 * @param ncol the ncol
87
	 * @throws RWorkspaceException the r workspace exception
88
	 */
89
	public void assign(String variablename, int[] matrix, int nrow, int ncol) throws RWorkspaceException
90
	{
91
		writeVector(matrix);
92
		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
93
		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- matrix(vectorint, nrow="+nrow+", ncol="+ncol+", byrow=T);"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
94
	}
95

  
96
	/**
97
	 * Assign.
98
	 *
99
	 * @param variablename the variablename
100
	 * @param matrix the matrix
101
	 * @param nrow the nrow
102
	 * @param ncol the ncol
103
	 * @throws RWorkspaceException the r workspace exception
104
	 */
105
	public void assign(String variablename, double[] matrix, int nrow, int ncol) throws RWorkspaceException
106
	{
107
		writeVector(matrix);
108
		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
109
		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- matrix(vectordouble, nrow="+nrow+", ncol="+ncol+", byrow=T);"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
110
	}
111

  
112
	/**
113
	 * Assign.
114
	 *
115
	 * @param variablename the variablename
116
	 * @param vector the vector
117
	 * @throws RWorkspaceException the r workspace exception
118
	 */
119
	public void assign(String variablename, int[] vector) throws RWorkspaceException
120
	{
121
		//System.out.println("assign vector "+variablename+" size "+vector.length);
122
		writeVector(vector);
123
		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
124
		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- vectorint;"); //$NON-NLS-1$
125
	}
126

  
127
	/**
128
	 * Assign.
129
	 *
130
	 * @param variablename the variablename
131
	 * @param vector the vector
132
	 * @throws RWorkspaceException the r workspace exception
133
	 */
134
	public void assign(String variablename, double[] vector) throws RWorkspaceException
135
	{
136
		//System.out.println("assign vector "+variablename+" size "+vector.length);
137
		writeVector(vector);
138
		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
139
		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- vectordouble;"); //$NON-NLS-1$
140
		
141
	}
142

  
143
	/**
144
	 * Assign.
145
	 *
146
	 * @param variablename the variablename
147
	 * @param vector the vector
148
	 * @throws RWorkspaceException the r workspace exception
149
	 */
150
	public void assign(String variablename, String[] vector) throws RWorkspaceException
151
	{
152
		//System.out.println("assign vector "+variablename+" size "+vector.length);
153
		writeVector(vector);
154
		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
155
		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- vectorstr;"); //$NON-NLS-1$
156
	}
157

  
158
	/*
159
	public boolean writeMatrix(int[][] matrix)
160
	{
161
		//System.out.println("WRITE MATRIX");
162
		try {
163
			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
164
			for(int i = 0 ; i < matrix.length ; i++)
165
			{
166
				StringBuffer str = new StringBuffer();
167
				for(int j = 0 ; j < matrix[i].length ; j++)
168
					if (j == matrix[i].length -1)
169
						str.append(matrix[i][j]);
170
					else
171
						str.append(""+matrix[i][j]+"\t");
172
				writer.write(str.toString()+"\n");
173
			}
174
			writer.close();
175
		} catch (IOException e) {
176
			org.txm.utils.logger.Log.printStackTrace(e);
177
			return false;
178
		}
179
		return true;
180
	}
181

  
182
	public boolean writeMatrix(double[][] matrix)
183
	{
184
		//System.out.println("WRITE MATRIX");
185
		try {
186
			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
187
			for(int i = 0 ; i < matrix.length ; i++)
188
			{
189
				StringBuffer str = new StringBuffer();
190
				for(int j = 0 ; j < matrix[i].length ; j++)
191
					if (j == matrix[i].length -1)
192
						str.append(matrix[i][j]);
193
					else
194
						str.append(""+matrix[i][j]+"\t");
195
				writer.write(str.toString()+"\n");
196
			}
197
			writer.close();
198
		} catch (IOException e) {
199
			org.txm.utils.logger.Log.printStackTrace(e);
200
			return false;
201
		}
202
		return true;
203
	}
204

  
205
*/
206
	/**
207
	 * Write vector.
208
	 *
209
	 * @param vector the vector
210
	 * @return true, if successful
211
	 */
212
	private boolean writeVector(String[] vector) {
213
		//System.out.println("WRITE VECTOR");
214
		try {
215
			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
216

  
217
			StringBuffer str = new StringBuffer();
218
			str.append("vectorstr <- c("); //$NON-NLS-1$
219
			for(int j = 0 ; j < vector.length ; j++)
220
				if (j == vector.length -1)
221
					str.append("\""+vector[j]+"\""); //$NON-NLS-1$ //$NON-NLS-2$
222
				else
223
					str.append("\""+vector[j]+"\", "); //$NON-NLS-1$ //$NON-NLS-2$
224
			str.append(");"); //$NON-NLS-1$
225
			writer.write(str.toString());
226

  
227
			writer.close();
228
		} catch (IOException e) {
229
			org.txm.utils.logger.Log.printStackTrace(e);
230
			return false;
231
		}
232
		return true;
233
	}
234

  
235
	/**
236
	 * Write vector.
237
	 *
238
	 * @param vector the vector
239
	 * @return true, if successful
240
	 */
241
	public boolean writeVector(int[] vector)
242
	{
243
		//System.out.println("WRITE VECTOR");
244
		try {
245
			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
246

  
247
			StringBuffer str = new StringBuffer();
248
			str.append("vectorint <- as.integer(c("); //$NON-NLS-1$
249
			for(int j = 0 ; j < vector.length ; j++)
250
				if (j == vector.length -1)
251
					str.append(vector[j]);
252
				else
253
					str.append(""+vector[j]+", "); //$NON-NLS-1$ //$NON-NLS-2$
254
			str.append("));"); //$NON-NLS-1$
255
			writer.write(str.toString());
256
			writer.close();
257
		} catch (IOException e) {
258
			org.txm.utils.logger.Log.printStackTrace(e);
259
			return false;
260
		}
261
		return true;
262
	}
263

  
264
	/**
265
	 * Write vector.
266
	 *
267
	 * @param vector the vector
268
	 * @return true, if successful
269
	 */
270
	public boolean writeVector(double[] vector)
271
	{
272
		//System.out.println("WRITE VECTOR");
273
		try {
274
			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
275

  
276
			StringBuffer str = new StringBuffer();
277
			str.append("vectordouble <- c("); //$NON-NLS-1$
278
			for(int j = 0 ; j < vector.length ; j++)
279
			{
280
				if (j == vector.length -1)
281
					str.append(vector[j]);
282
				else
283
					str.append(""+vector[j]+", "); //$NON-NLS-1$ //$NON-NLS-2$
284
			}
285
			str.append(");"); //$NON-NLS-1$
286
			writer.write(str.toString());
287
			writer.close();
288
		} catch (IOException e) {
289
			org.txm.utils.logger.Log.printStackTrace(e);
290
			return false;
291
		}
292
		return true;
293
	}
294

  
295
	/**
296
	 * The main method.
297
	 *
298
	 * @param args the arguments
299
	 */
300
	public static void main(String[] args)
301
	{
302
		double[][] matrix ={{1,2,3}, {4,5,6}, {7,8,9}};
303
		RFileCommunication comm;
304
		try {
305
			comm = new RFileCommunication();
306
		} catch (IOException e) {
307
			org.txm.utils.logger.Log.printStackTrace(e);
308
			return;
309
		}
310

  
311
		//comm.writeMatrix(matrix);
312
	}
313
}
0 314

  
tmp/org.txm.r.core/src/org/txm/stat/engine/r/data/ContingencyTableImpl.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.stat.engine.r.data;
29

  
30
import org.rosuda.REngine.REXPMismatchException;
31
import org.txm.stat.StatException;
32
import org.txm.stat.data.ContingencyTable;
33
import org.txm.stat.data.Vector;
34
import org.txm.stat.engine.r.RWorkspaceException;
35
import cern.colt.matrix.DoubleMatrix2D;
36

  
37
// TODO: Auto-generated Javadoc
38
/**
39
 * Implementation of the {@link ContingencyTable} interface, wrapping a R
40
 * matrix.
41
 * 
42
 * @author sloiseau
43
 */
44
public class ContingencyTableImpl extends MatrixImpl implements
45
		ContingencyTable {
46

  
47
	/**
48
	 * Create a new contingency table after a {@link DoubleMatrix2D}.
49
	 *
50
	 * @param matrix the matrix
51
	 * @throws RWorkspaceException the r workspace exception
52
	 */
53
	public ContingencyTableImpl(DoubleMatrix2D matrix)
54
			throws RWorkspaceException {
55
		super(matrix);
56
	}
57

  
58
	/**
59
	 * Create a new contingency table after a {@link DoubleMatrix2D}, with row
60
	 * names and column names.
61
	 *
62
	 * @param matrix the matrix
63
	 * @param rowNames row names.
64
	 * @param columnNames the column names
65
	 * @throws RWorkspaceException the r workspace exception
66
	 */
67
	public ContingencyTableImpl(DoubleMatrix2D matrix, String[] rowNames,
68
			String[] columnNames) throws RWorkspaceException {
69
		super(matrix, rowNames, columnNames);
70
	}
71

  
72
	/**
73
	 * Instantiates a new contingency table impl.
74
	 *
75
	 * @param matrix the matrix
76
	 * @param formNames the form names
77
	 * @param partNames the part names
78
	 * @throws RWorkspaceException the r workspace exception
79
	 */
80
	public ContingencyTableImpl(int[][] matrix, String[] formNames,
81
			String[] partNames) throws RWorkspaceException {
82
		super(matrix, formNames, partNames);
83
	}
84
	
85
	/**
86
	 * See {@link MatrixImpl#Matrix(String, Header)}.
87
	 *
88
	 * @param symbol the name of the object
89
	 * @throws RWorkspaceException the r workspace exception
90
	 */
91
	public ContingencyTableImpl(String symbol) throws RWorkspaceException {
92
		super(symbol);
93
	}
94

  
95

  
96

  
97
	/* (non-Javadoc)
98
	 * @see org.txm.stat.data.ContingencyTable#getColMargin()
99
	 */
100
	public Vector getColMargin() throws RWorkspaceException {
101
		String colName = createSymbole(Vector.class);
102
		rw.voidEval(colName + "<- colSums(" + this.symbol + ");"); //$NON-NLS-1$ //$NON-NLS-2$
103
		return new VectorImpl(colName);
104
	}
105

  
106
	/* (non-Javadoc)
107
	 * @see org.txm.stat.data.ContingencyTable#getRowMargin()
108
	 */
109
	@Override
110
	public Vector getRowMarginsVector() throws StatException {
111
		String colName = createSymbole(Vector.class);
112
		rw.voidEval(colName + "<- rowSums(" + this.symbol + ");"); //$NON-NLS-1$ //$NON-NLS-2$
113
		return new VectorImpl(colName);
114
	}
115

  
116
	/* (non-Javadoc)
117
	 * @see org.txm.stat.data.ContingencyTable#getRowMargin()
118
	 */
119
	@Override
120
	public Vector getColMarginsVector() throws StatException {
121
		String rowName = createSymbole(Vector.class);
122
		try {
123
			rw.voidEval(rowName + "<- colSums(" + this.symbol + ");"); //$NON-NLS-1$ //$NON-NLS-2$
124
			return new VectorImpl(rowName);
125
		} catch (RWorkspaceException e) {
126
			throw new StatException(e);
127
		} 
128
		
129
	}
130
	
131
	/* (non-Javadoc)
132
	 * @see org.txm.stat.data.ContingencyTable#getTotal()
133
	 */
134
	@Override
135
	public int getTotal() throws RWorkspaceException {
136
		int total;
137
		try {
138
			total = rw.eval("sum(" + this.symbol + ");").asInteger(); //$NON-NLS-1$ //$NON-NLS-2$
139
		} catch (REXPMismatchException e) {
140
			throw new RWorkspaceException(e);
141
		}
142
		return total;
143
	}
144

  
145
	// /**
146
	// * Gets the col.
147
	// *
148
	// * @param index the index
149
	// *
150
	// * @return the col
151
	// */
152
	// public DoubleMatrix1D getCol(int index) {
153
	// if (index < 0 || index >= matrix.columns()) {
154
	// throw new IllegalArgumentException("Column index (" + index +
155
	// ") too hight (max: " + matrix.columns() + ")");
156
	// }
157
	// return matrix.viewColumn(index);
158
	// }
159
	//
160
	// /**
161
	// * Gets the sum.
162
	// *
163
	// * @return the sum
164
	// */
165
	// public int getSum() {
166
	// if (sum == -1) {
167
	// sum = (int) this.matrix.zSum();
168
	// }
169
	// return sum;
170
	// }
171
	//
172
	//	
173
	// /**
174
	// * Row margin.
175
	// *
176
	// * @return the sum over the rows
177
	// */
178
	// public DoubleMatrix1D getRowSum() {
179
	// if (rowSum==null){
180
	// DoubleMatrix1D ones = DoubleFactory1D.dense.make(matrix.rows(),1);
181
	// rowSum = matrix.viewDice().zMult(ones, null);
182
	// }
183
	// return rowSum;
184
	// }
185
	//	
186
	//
187
	//
188
	// /**
189
	// * Col margin.
190
	// *
191
	// * @return the sum over the columns
192
	// */
193
	// public DoubleMatrix1D getColSum() {
194
	// if (colSum==null){
195
	// DoubleMatrix1D ones = DoubleFactory1D.dense.make(matrix.columns(),1);
196
	// colSum = matrix.zMult(ones, null);
197
	// }
198
	// return colSum;
199
	// }
200

  
201
	/**
202
	 * Apply a four paramters-function on the whole table.
203
	 * 
204
	 * For each non zero value, the function will received four parameters:
205
	 * <ul>
206
	 * <li>The sum of the values in the matrix</li>
207
	 * <li>The sum of the row of the given value</li>
208
	 * <li>The sum of the column of the given value</li>
209
	 * <li>The value</li>
210
	 * </ul>
211
	 * 
212
	 * @param fun
213
	 *            the fun
214
	 * 
215
	 * @return the matrix
216
	 */
217
	// public Matrix apply(final AbstractMatrixIntIntIntDoubleFunction fun) {
218
	// cacheColSum();
219
	// cacheRowSum();
220
	// cacheSum();
221
	// return new Matrix(
222
	// matrix.copy().forEachNonZero(
223
	// new IntIntDoubleFunction() {
224
	// public double apply(int row, int col, double value) {
225
	// return fun.apply(sum, rowSum[row], colSum[col], value);
226
	// }
227
	// }
228
	// )
229
	// );
230
	// }
231

  
232
	/**
233
	 * Apply a function on the given row.
234
	 * 
235
	 * For each non zero value, the function will received four parameters:
236
	 * <ul>
237
	 * <li>The sum of the values in the matrix</li>
238
	 * <li>The sum of the row of the given value</li>
239
	 * <li>The sum of the column of the given value</li>
240
	 * <li>The value</li>
241
	 * </ul>
242
	 * 
243
	 * @param fun
244
	 *            the fun
245
	 * @param rowIndex
246
	 *            the row index
247
	 * 
248
	 * @return the variable
249
	 */
250
	// public NumericalVector applyOnRowWithMargin(final
251
	// AbstractMatrixIntIntIntDoubleFunction fun, int rowIndex) {
252
	// cacheColSum();
253
	// cacheRowSum();
254
	// cacheSum();
255
	// IntArrayList indexList = new IntArrayList();
256
	// DoubleArrayList valueList = new DoubleArrayList();
257
	// matrix.viewRow(rowIndex).getNonZeros(indexList, valueList);
258
	//
259
	// DoubleArrayList result = new DoubleArrayList(indexList.size());
260
	//
261
	// for (int i = 0; i < indexList.size(); i++) {
262
	// int column = indexList.getQuick(i);
263
	// double value = valueList.getQuick(i);
264
	// result.setQuick(i, fun.apply(sum, rowSum[rowIndex], colSum[column],
265
	// value));
266
	// }
267
	//
268
	// return new NumericalVector(result);
269
	// }
270

  
271
	/**
272
	 * Apply a function on the given column.
273
	 * 
274
	 * For each non zero value, the function will received four parameters:
275
	 * <ul>
276
	 * <li>The sum of the values in the matrix</li>
277
	 * <li>The sum of the row of the given value</li>
278
	 * <li>The sum of the column of the given value</li>
279
	 * <li>The value</li>
280
	 * </ul>
281
	 * 
282
	 * @param fun
283
	 *            the fun
284
	 * @param columnIndex
285
	 *            the column index
286
	 * 
287
	 * @return the variable
288
	 */
289
	// public NumericalVector applyOnColumnWithMargin(final
290
	// AbstractMatrixIntIntIntDoubleFunction fun, int columnIndex) {
291
	// cacheColSum();
292
	// cacheRowSum();
293
	// cacheSum();
294
	// IntArrayList indexList = new IntArrayList();
295
	// DoubleArrayList valueList = new DoubleArrayList();
296
	// matrix.viewColumn(columnIndex).getNonZeros(indexList, valueList);
297
	//
298
	// DoubleArrayList result = new DoubleArrayList(indexList.size());
299
	//
300
	// for (int i = 0; i < indexList.size(); i++) {
301
	// int row = indexList.getQuick(i);
302
	// double value = valueList.getQuick(i);
303
	// result.setQuick(i, fun.apply(sum, rowSum[row], colSum[columnIndex],
304
	// value));
305
	// }
306
	// return new NumericalVector(result);
307
	// }
308

  
309
	// /**
310
	// * For each non zero value in the matrix, get its row in the
311
	// * first list, its column in the second list, and its value
312
	// * in the third list.
313
	// *
314
	// * This is a strict delegation to {@link
315
	// DoubleMatrix2D#getNonZeros(IntArrayList, IntArrayList, DoubleArrayList)}.
316
	// *
317
	// * @param rowList
318
	// * @param columnList
319
	// * @param valueList
320
	// */
321
	// public void getNonZeros(IntArrayList rowList, IntArrayList columnList,
322
	// DoubleArrayList valueList) {
323
	// matrix.getNonZeros(rowList, columnList, valueList);
324
	// }
325

  
326
	/**
327
	 * For each non zero value in the matrix, get its row in the first list, its
328
	 * column in the second list, its value in the third list, the total of the
329
	 * column of the value in the fourth list, and the total of the row of the
330
	 * value in the firth list.
331
	 * 
332
	 * @param rowList
333
	 * @param columnList
334
	 * @param valueList
335
	 * @param columnMargin
336
	 * @param rowMargin
337
	 */
338
	// public void getNonZerosWithMargin(
339
	// IntArrayList rowList,
340
	// IntArrayList columnList,
341
	// DoubleArrayList valueList,
342
	// IntArrayList columnMargin,
343
	// IntArrayList rowMargin
344
	// ) {
345
	// I'm not sure to understand what this function does, but I'm pretty sure
346
	// it's buggy
347
	// cacheColSum();
348
	// cacheRowSum();
349
	// matrix.getNonZeros(rowList, columnList, valueList);
350
	// columnMargin.setSize(rowList.size());
351
	// rowMargin.setSize(rowList.size());
352
	// for (int i = 0; i < rowList.size(); i++) {
353
	// columnMargin.setQuick(i, colSum[columnList.getQuick(i)]);
354
	// rowMargin.setQuick(i, rowSum[rowList.getQuick(i)]);
355
	// }
356
	// }
357
}
0 358

  
tmp/org.txm.r.core/src/org/txm/stat/engine/r/data/QuantitativeDataStructureImpl.java (revision 210)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.stat.engine.r.data;
29

  
30
import org.rosuda.REngine.REXP;
31
import org.txm.stat.data.QuantitativeDataStructure;
32
import org.txm.stat.data.Vector;
33
import org.txm.stat.engine.r.RWorkspace;
34
import org.txm.stat.engine.r.RWorkspaceException;
35
import org.txm.Messages;
36

  
37
// TODO: Auto-generated Javadoc
38
/**
39
 * The root of the hierarchy for all classes wrapping R data.
40
 * 
41
 * @author Sylvain Loiseau &lt;sloiseau@ens-lsh.fr&gt;
42
 */
43
public abstract class QuantitativeDataStructureImpl implements
44
		QuantitativeDataStructure {
45
	
46
	/** The counter. */
47
	private static int counter = 1;
48

  
49
	/**
50
	 * An immutable symbol for the name of this data structure in the R
51
	 * workspace.
52
	 */
53
	protected String symbol;
54

  
55
	/** The R workspace. */
56
	protected final RWorkspace rw;
57

  
58
	/**
59
	 * This constructor is called by every sub-classes for initializing final
60
	 * fields header and symbol.
61
	 *
62
	 * @throws RWorkspaceException the r workspace exception
63
	 */
64
	protected QuantitativeDataStructureImpl() throws RWorkspaceException {
65
		this.symbol = createSymbole();
66
		this.rw = RWorkspace.getRWorkspaceInstance();
67
	}
68

  
69
	/**
70
	 * This constructor is called by every sub-classes for initializing final
71
	 * fields header and symbol.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff