Révision 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/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/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/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/data/DoubleMatrix.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.txm.stat.engine.r.RWorkspaceException;
31

  
32
import cern.colt.matrix.DoubleMatrix2D;
33

  
34
// TODO: Auto-generated Javadoc
35
/**
36
 * A double matrix, backed to the R engine.
37
 * 
38
 * @author sloiseau
39
 */
40
public class DoubleMatrix extends MatrixImpl {
41

  
42
	/**
43
	 * Instantiates a new double matrix.
44
	 *
45
	 * @param matrix the matrix
46
	 * @throws RWorkspaceException the r workspace exception
47
	 */
48
	public DoubleMatrix(DoubleMatrix2D matrix) throws RWorkspaceException {
49
		super(matrix);
50
		// TODO Auto-generated constructor stub
51
	}
52

  
53
	/**
54
	 * Instantiates a new double matrix.
55
	 *
56
	 * @param mat the mat
57
	 * @throws RWorkspaceException the r workspace exception
58
	 */
59
	public DoubleMatrix(double[][] mat) throws RWorkspaceException {
60
		super(mat);
61
	}
62

  
63
	/**
64
	 * Instantiates a new double matrix.
65
	 *
66
	 * @param symbol the symbol
67
	 * @throws RWorkspaceException the r workspace exception
68
	 */
69
	public DoubleMatrix(String symbol) throws RWorkspaceException {
70
		super(symbol);
71
		// TODO Auto-generated constructor stub
72
	}
73

  
74
	/**
75
	 * Instantiates a new double matrix.
76
	 *
77
	 * @param matrix the matrix
78
	 * @param rowNames the row names
79
	 * @param columnNames the column names
80
	 * @throws RWorkspaceException the r workspace exception
81
	 */
82
	public DoubleMatrix(DoubleMatrix2D matrix, String[] rowNames,
83
			String[] columnNames) throws RWorkspaceException {
84
		super(matrix, rowNames, columnNames);
85
		// TODO Auto-generated constructor stub
86
	}
87

  
88
}
0 89

  
tmp/org.txm.r.core/src/org/txm/stat/engine/r/data/RObjectDoesNotExist.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.txm.stat.engine.r.RWorkspaceException;
31

  
32
// TODO: Auto-generated Javadoc
33
/**
34
 * Exception thrown if a symbol without corresponding object in the R workspace
35
 * is used.
36
 * 
37
 * @author sloiseau
38
 */
39
public class RObjectDoesNotExist extends RWorkspaceException {
40

  
41
	/** The Constant serialVersionUID. */
42
	private static final long serialVersionUID = -1344530765750521820L;
43

  
44
	/**
45
	 * Instantiates a new r object does not exist.
46
	 */
47
	public RObjectDoesNotExist() {
48
		super();
49
	}
50

  
51
	/**
52
	 * Instantiates a new r object does not exist.
53
	 *
54
	 * @param arg0 the arg0
55
	 * @param arg1 the arg1
56
	 */
57
	public RObjectDoesNotExist(String arg0, Throwable arg1) {
58
		super(arg0, arg1);
59
	}
60

  
61
	/**
62
	 * Instantiates a new r object does not exist.
63
	 *
64
	 * @param arg0 the arg0
65
	 */
66
	public RObjectDoesNotExist(String arg0) {
67
		super(arg0);
68
	}
69

  
70
	/**
71
	 * Instantiates a new r object does not exist.
72
	 *
73
	 * @param arg0 the arg0
74
	 */
75
	public RObjectDoesNotExist(Throwable arg0) {
76
		super(arg0);
77
	}
78

  
79
}
0 80

  
tmp/org.txm.r.core/src/org/txm/stat/engine/r/data/VectorImpl.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-08-29 14:23:55 +0200 (Thu, 29 Aug 2013) $
25
// $LastChangedRevision: 2519 $
26
// $LastChangedBy: nilskredens $ 
27
//
28
package org.txm.stat.engine.r.data;
29

  
30
import java.util.List;
31

  
32
import org.rosuda.REngine.REXP;
33
import org.rosuda.REngine.REXPMismatchException;
34
import org.txm.stat.StatException;
35
import org.txm.stat.data.Vector;
36
import org.txm.stat.engine.r.RWorkspaceException;
37
import org.txm.stat.utils.ArrayIndex;
38

  
39
// TODO: Auto-generated Javadoc
40
/**
41
 * Implementation of the {@link Vector} interface, wrapping a R vector.
42
 * 
43
 * @author sloiseau
44
 */
45
public class VectorImpl extends QuantitativeDataStructureImpl implements Vector {
46

  
47
	/**
48
	 * This is final in order to be sure that a length is always defined, and
49
	 * defined only once, on a vector.
50
	 */
51
	private int length;
52

  
53
	/**
54
	 * Instantiates a new vector.
55
	 *
56
	 * @param data the data
57
	 * @throws RWorkspaceException the r workspace exception
58
	 */
59
	public VectorImpl(int[] data) throws RWorkspaceException {
60
		super();
61
		rw.addVectorToWorkspace(symbol, data);
62
		length = data.length;
63
	}
64

  
65
	/**
66
	 * Instantiates a new vector impl.
67
	 *
68
	 * @param data the data
69
	 * @throws RWorkspaceException the r workspace exception
70
	 */
71
	public VectorImpl(double[] data) throws RWorkspaceException {
72
		super();
73
		rw.addVectorToWorkspace(symbol, data);
74
		length = data.length;
75
	}
76

  
77
	/**
78
	 * Instantiates a new vector impl.
79
	 *
80
	 * @param data the data
81
	 * @throws RWorkspaceException the r workspace exception
82
	 */
83
	public VectorImpl(String[] data) throws RWorkspaceException {
84
		super();
85
		rw.addVectorToWorkspace(symbol, data);
86
		length = data.length;
87
	}
88
	
89
	/**
90
	 * Instantiates a new vector.
91
	 *
92
	 * @param data the data
93
	 * @param symbol the symbol
94
	 * @throws RWorkspaceException the r workspace exception
95
	 */
96
	public VectorImpl(int[] data, String symbol) throws RWorkspaceException {
97
		super();
98
		this.symbol = symbol;
99
		rw.addVectorToWorkspace(symbol, data);
100
		length = data.length;
101
	}
102

  
103
	/**
104
	 * Instantiates a new vector impl.
105
	 *
106
	 * @param data the data
107
	 * @param symbol the symbol
108
	 * @throws RWorkspaceException the r workspace exception
109
	 */
110
	public VectorImpl(double[] data, String symbol) throws RWorkspaceException {
111
		super();
112
		this.symbol = symbol;
113
		rw.addVectorToWorkspace(symbol, data);
114
		length = data.length;
115
	}
116

  
117
	/**
118
	 * Instantiates a new vector impl.
119
	 *
120
	 * @param data the data
121
	 * @param symbol the symbol
122
	 * @throws RWorkspaceException the r workspace exception
123
	 */
124
	public VectorImpl(String[] data, String symbol) throws RWorkspaceException {
125
		super();
126
		this.symbol = symbol;
127
		rw.addVectorToWorkspace(symbol, data);
128
		length = data.length;
129
	}
130

  
131
	/**
132
	 * Constructing a Vector when the R object already exists in the workspace:
133
	 * we only want to record its symbol in a java object.
134
	 *
135
	 * @param symbol the symbol
136
	 * @throws RWorkspaceException the r workspace exception
137
	 */
138
	public VectorImpl(String symbol) throws RWorkspaceException {
139
		super(symbol);
140
		try {
141
			length = rw.eval("length(" + symbol + ")").asInteger(); //$NON-NLS-1$ //$NON-NLS-2$
142
		} catch (REXPMismatchException e) {
143
			throw new RWorkspaceException(e);
144
		}
145
	}
146

  
147
	/**
148
	 * Sets the r names.
149
	 *
150
	 * @param vals the new r names
151
	 * @throws RWorkspaceException the r workspace exception
152
	 */
153
	public void setRNames(String[] vals) throws RWorkspaceException {
154
		Vector names = new VectorImpl(vals);
155

  
156
		StringBuffer exp = new StringBuffer();
157
		exp.append("names("); //$NON-NLS-1$
158
		exp.append(symbol);
159
		exp.append(")"); //$NON-NLS-1$
160
		exp.append("<-"); //$NON-NLS-1$
161
		exp.append(names.getSymbol());
162
		exp.append(";"); //$NON-NLS-1$
163

  
164
		rw.voidEval(exp.toString());
165
		rw.voidEval("rm(" + names.getSymbol() + ");"); //$NON-NLS-1$ //$NON-NLS-2$
166
	}
167

  
168
	/**
169
	 * Gets the r names.
170
	 * 
171
	 * @param string
172
	 *            the string
173
	 * 
174
	 * @return the r names
175
	 * 
176
	 * @throws RWorkspaceException
177
	 *             the r workspace exception
178
	 */
179
	public void getRNames(String[] string) throws RWorkspaceException {
180
		getAttribute("names"); //$NON-NLS-1$
181
	}
182

  
183
	/**
184
	 * Get a new vector with a copy of the value at the specif ied index in this
185
	 * vector.
186
	 *
187
	 * @param index the index
188
	 * @return the vector
189
	 * @throws RWorkspaceException the r workspace exception
190
	 */
191
	@Override
192
	public Vector get(int[] index) throws RWorkspaceException {
193
		int[] rIndex = ArrayIndex.zeroToOneBasedIndex(index, this.length);
194
		// TODO Auto-generated method stub
195
		String name_index = createSymbole(Vector.class);
196
		rw.addVectorToWorkspace(name_index, rIndex);
197
		String name = createSymbole(Vector.class);
198
		rw.voidEval(name + "<- " + symbol + "[ " + name_index + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
199
		return new VectorImpl(name);
200
	}
201

  
202
	/**
203
	 * Throw a {@link RWorkspaceException} if the vector is not of type integer.
204
	 *
205
	 * @return the int[]
206
	 * @throws RWorkspaceException the r workspace exception
207
	 */
208
	@Override
209
	public int[] asIntArray() throws RWorkspaceException {
210
		try {
211
			return rw.eval(symbol).asIntegers();
212
		} catch (REXPMismatchException e) {
213
			throw new RWorkspaceException(e);
214
		}
215
	}
216

  
217
	/* (non-Javadoc)
218
	 * @see org.txm.stat.data.Vector#asStringsArray()
219
	 */
220
	@Override
221
	public String[] asStringsArray() throws StatException {
222
		try {
223
			return rw.eval(symbol).asStrings();
224
		} catch (REXPMismatchException e) {
225
			throw new RWorkspaceException(e);
226
		}
227
	}
228

  
229
	/* (non-Javadoc)
230
	 * @see org.txm.stat.data.Vector#asDoubleArray()
231
	 */
232
	@Override
233
	public double[] asDoubleArray() throws StatException {
234
		try {
235
			return rw.eval(symbol).asDoubles();
236
		} catch (REXPMismatchException e) {
237
			throw new RWorkspaceException(e);
238
		}
239
	}
240

  
241
	/* (non-Javadoc)
242
	 * @see org.txm.stat.data.Vector#getLength()
243
	 */
244
	@Override
245
	public int getLength() throws StatException {
246
		return length;
247
	}
248

  
249
	/* (non-Javadoc)
250
	 * @see org.txm.stat.data.Vector#remove(int)
251
	 */
252
	@Override
253
	public boolean remove(int index) {
254
		try {
255
			if (index < this.length) {
256
				rw.eval(symbol + " <- " + symbol + "[-" + (index + 1) + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
257
				length--;
258
			}
259
		} catch (RWorkspaceException e) {
260
			org.txm.utils.logger.Log.printStackTrace(e);
261
			return false;
262
		}
263
		return true;
264
	}
265

  
266
	/* (non-Javadoc)
267
	 * @see org.txm.stat.data.Vector#setString(int, java.lang.String)
268
	 */
269
	@Override
270
	public void setString(int index, String value) {
271
		try {
272
			if (index < this.length) {
273
				rw.eval(symbol + "[" + (index + 1) + "] <-\"" + value + "\";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
274
			}
275
		} catch (RWorkspaceException e) {
276
			org.txm.utils.logger.Log.printStackTrace(e);
277
		}
278
	}
279

  
280
	/* (non-Javadoc)
281
	 * @see org.txm.stat.data.Vector#setDouble(int, double)
282
	 */
283
	@Override
284
	public void setDouble(int index, double value) {
285
		try {
286
			if (index < this.length) {
287
				rw.eval(symbol + "[" + (index + 1) + "] <-" + value + ";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
288
			}
289
		} catch (RWorkspaceException e) {
290
			org.txm.utils.logger.Log.printStackTrace(e);
291
		}
292
	}
293

  
294
	/* (non-Javadoc)
295
	 * @see org.txm.stat.data.Vector#setInt(int, int)
296
	 */
297
	@Override
298
	public void setInt(int index, int value) {
299
		try {
300
			if (index < this.length) {
301
				rw.eval(symbol + "[" + (index + 1) + "] <-" + value + ";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
302
			}
303
		} catch (RWorkspaceException e) {
304
			org.txm.utils.logger.Log.printStackTrace(e);
305
		}
306
	}
307

  
308
	/* (non-Javadoc)
309
	 * @see org.txm.stat.data.Vector#sort(java.lang.Boolean)
310
	 */
311
	@Override
312
	public void sort(Boolean reverse) {
313
		try {
314
			//System.out.println("R sort rownames Reverse" + reverse);
315
			REXP r = rw
316
					.eval(symbol
317
							+ "<- " + symbol + "[order(" + symbol + ", decreasing = " + reverse.toString().toUpperCase() + ")];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
318
		} catch (RWorkspaceException e) {
319
			// TODO Auto-generated catch block
320
			org.txm.utils.logger.Log.printStackTrace(e);
321
		}
322
	}
323

  
324
	/* (non-Javadoc)
325
	 * @see org.txm.stat.data.Vector#setOrder(java.util.List, java.lang.Boolean)
326
	 */
327
	@Override
328
	public void setOrder(List<Integer> neworder, Boolean reverse) {
329
		if (neworder.size() != this.length)
330
			return;
331
		String order = "c("; //$NON-NLS-1$
332
		if (reverse) {
333
			for (int i = neworder.size() - 1; i >= 0; i--)
334
				order += "" + (neworder.get(i) + 1) + ", "; //$NON-NLS-1$ //$NON-NLS-2$
335
		} else {
336
			for (Integer i : neworder)
337
				order += "" + (i + 1) + ", "; //$NON-NLS-1$ //$NON-NLS-2$
338
		}
339
		order = order.substring(0, order.length() - 2);
340
		order += ")"; //$NON-NLS-1$
341
		try {
342
			// System.out.println("R sort rownames Reverse"+reverse);
343
			REXP r = rw.eval(symbol + "<- " + symbol + "[" + order + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
344
		} catch (RWorkspaceException e) {
345
			// TODO Auto-generated catch block
346
			org.txm.utils.logger.Log.printStackTrace(e);
347
		}
348
	}
349

  
350
	/* (non-Javadoc)
351
	 * @see org.txm.stat.data.Vector#cut(int)
352
	 */
353
	@Override
354
	public void cut(int nlines) {
355
		try {
356
			// cut nlines
357
			REXP r = rw.eval(symbol + "<- " + symbol + "[1:" + (nlines) + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
358
		} catch (RWorkspaceException e) {
359
			// TODO Auto-generated catch block
360
			org.txm.utils.logger.Log.printStackTrace(e);
361
		}
362
	}
363
}
0 364

  
tmp/org.txm.r.core/src/org/txm/stat/engine/r/data/MatrixImpl.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.data;
29

  
30
import java.io.BufferedReader;
31
import java.io.File;
32
import java.io.FileInputStream;
33
import java.io.InputStreamReader;
34
import java.util.ArrayList;
35
import java.util.Arrays;
36
import java.util.Collections;
37
import java.util.List;
38

  
39
import org.eclipse.core.runtime.Platform;
40
import org.rosuda.REngine.REXP;
41
import org.rosuda.REngine.REXPMismatchException;
42
import org.txm.stat.StatException;
43
import org.txm.stat.data.Matrix;
44
import org.txm.stat.data.Vector;
45
import org.txm.stat.engine.r.RException;
46
import org.txm.stat.engine.r.RWorkspace;
47
import org.txm.stat.engine.r.RWorkspaceException;
48
import org.txm.stat.utils.ArrayIndex;
49
import org.txm.utils.CharsetDetector;
50
import org.txm.utils.OSDetector;
51

  
52
import cern.colt.matrix.DoubleMatrix2D;
53

  
54
import org.txm.Messages;
55

  
56
// TODO: Auto-generated Javadoc
57
/**
58
 * Implementation of the {@link Matrix} interface, wrapping a R matrix.
59
 * 
60
 * define the methods to edit/delete elements in the matrix
61
 * 
62
 * @author sloiseau
63
 */
64
public class MatrixImpl extends QuantitativeDataStructureImpl
65
implements Matrix {
66

  
67

  
68
	public static int[][] asIntMatrix(REXP r) throws REXPMismatchException {
69

  
70
		int[] ct = r.asIntegers();
71
		if (ct == null) return null;
72
		REXP dim = r.getAttribute("dim"); //$NON-NLS-1$
73
		int[] ds = dim.asIntegers();
74
		if (ds == null || ds.length != 2)
75
			return null; // matrix must be 2-dimensional
76

  
77
		int m = ds[0], n = ds[1];
78
		int[][] rez = new int[m][n];
79

  
80
		// R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4)
81
		// we need to copy everything, since we create 2d array from 1d array
82
		int i = 0, k = 0;
83
		while (i < n) {
84
			int j = 0;
85
			while (j < m) {
86
				rez[j++][i] = ct[k++];
87
			}
88
			i++;
89
		}
90
		return rez;
91
	}
92

  
93
	//	/** The ncol. */
94
	//	protected int ncol;
95
	//	
96
	//	/** The nrow. */
97
	//	protected int nrow;
98

  
99

  
100
	/**
101
	 * Instantiates a new matrix impl.
102
	 *
103
	 * @param matrix the matrix
104
	 * @throws RWorkspaceException the r workspace exception
105
	 */
106
	public MatrixImpl(double[][] matrix) throws RWorkspaceException {
107
		super();
108
		rw.addMatrixToWorkspace(symbol, matrix);
109
		//		this.nrow = matrix.length;
110
		//		this.ncol = matrix[0].length;
111
		//this.rows = null;
112
		//this.cols = null;
113
	}
114

  
115
	/**
116
	 * Instantiates a new matrix impl.
117
	 *
118
	 * @param matrix the matrix
119
	 * @throws RWorkspaceException the r workspace exception
120
	 */
121
	public MatrixImpl(DoubleMatrix2D matrix) throws RWorkspaceException {
122
		super();
123
		rw.addMatrixToWorkspace(symbol, matrix);
124
		//		this.nrow = matrix.rows();
125
		//		this.ncol = matrix.columns();
126
		//this.rows = null;
127
		//this.cols = null;
128
	}
129

  
130
	/**
131
	 * Create a new matrix given a {@link DoubleMatrix2D}, with row and col
132
	 * names.
133
	 *
134
	 * @param matrix the matrix
135
	 * @param rowNames row names.
136
	 * @param columnNames the column names
137
	 * @throws RWorkspaceException the r workspace exception
138
	 */
139
	public MatrixImpl(DoubleMatrix2D matrix, String[] rowNames,
140
			String[] columnNames) throws RWorkspaceException {
141
		this(matrix);
142

  
143
		if (rowNames == null) {
144
			throw new IllegalArgumentException(Messages.MatrixImpl_4);
145
		}
146
		//		if (rowNames.length != nrow) {
147
		//			throw new IllegalArgumentException(Messages.MatrixImpl_5);
148
		//		}
149
		//this.rows = new VectorImpl(rowNames);
150
		rw.assignRowNamesToMatrix(symbol, new VectorImpl(rowNames).getSymbol());
151

  
152
		if (columnNames == null) {
153
			throw new IllegalArgumentException(Messages.MatrixImpl_6);
154
		}
155
		//		if (columnNames.length != ncol) {
156
		//			throw new IllegalArgumentException(Messages.MatrixImpl_7
157
		//					+ columnNames.length + ", " + ncol + ")."); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
158
		//		}
159
		//this.cols = new VectorImpl(columnNames);
160
		rw.assignColNamesToMatrix(symbol, new VectorImpl(columnNames).getSymbol());
161

  
162
	}
163

  
164
	/**
165
	 * Instantiates a new matrix impl.
166
	 *
167
	 * @param matrix the matrix
168
	 * @throws RWorkspaceException the r workspace exception
169
	 */
170
	public MatrixImpl(int[][] matrix) throws RWorkspaceException {
171
		super();
172
		rw.addMatrixToWorkspace(symbol, matrix);
173
		//		this.nrow = matrix.length;
174
		//		if (matrix.length > 0)
175
		//			this.ncol = matrix[0].length;
176
		//		else
177
		//			this.ncol = 0;
178
		//this.rows = null;
179
		//this.cols = null;
180
	}
181
	
182
	public void exchangeColumns(int c1, int c2) {
183
		try {
184
			RWorkspace rw = RWorkspace.getRWorkspaceInstance();
185
			rw.eval("tmp <- "+symbol+"[,"+c1+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
186
			rw.eval(symbol+"[,"+c1+"] <- "+symbol+"[,"+c2+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
187
			rw.eval(symbol+"[,"+c2+"] <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$
188
			rw.eval("tmp <- colnames("+symbol+")["+c1+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
189
			rw.eval("colnames("+symbol+")["+c1+"] <- colnames("+symbol+")["+c2+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
190
			rw.eval("colnames("+symbol+")["+c2+"] <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
191
		} catch (RWorkspaceException e) {
192
			// TODO Auto-generated catch block
193
			org.txm.utils.logger.Log.printStackTrace(e);
194
		}
195
	}
196

  
197
	/**
198
	 * Instantiates a new matrix impl.
199
	 *
200
	 * @param matrix the matrix
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff