@@ -111,6 +111,163 @@ public static BoaTup[][] matrix(final BoaTup[] a, final long colsize) {
111111 return result ;
112112 }
113113
114+ /**
115+ * Returns the matrix version of an array. Only scalar values can be sorted.
116+ * Values will be arranged in increasing order. (An optional comparison
117+ * function, which takes two elements and returns int {-,0,+}, is accepted
118+ * as a second argument, but it is curently ignored.)
119+ *
120+ * @param a
121+ * An array of long
122+ *
123+ * @return A sorted copy of <em>a</em>
124+ */
125+ @ FunctionSpec (name = "multiply" , returnType = "array of array of int" , formalParameters = { "array of array of int" , "array of array of int" })
126+ public static long [][] multiply (final long [][] a , final long [][] b ) {
127+ double [][] a_double = new double [a .length ][];
128+ double [][] b_double = new double [b .length ][];
129+
130+ for (int i = 0 ; i < a .length ; i ++){
131+ a_double [i ] = Doubles .toArray (Longs .asList (a [i ]));
132+ }
133+
134+ for (int i = 0 ; i < b .length ; i ++){
135+ b_double [i ] = Doubles .toArray (Longs .asList (b [i ]));
136+ }
137+ Matrix a_matrix = new Matrix (a_double );
138+ Matrix b_matrix = new Matrix (b_double );
139+ double [][] result = a_matrix .times (b_matrix ).getArray ();
140+ long [][]result_long = new long [result .length ][];
141+ for (int i = 0 ; i < result .length ; i ++){
142+ result_long [i ] = Longs .toArray (Doubles .asList (result [i ]));
143+ }
144+ return result_long ;
145+ }
146+
147+
148+
149+ /**
150+ * Returns the matrix version of an array. Only scalar values can be sorted.
151+ * Values will be arranged in increasing order. (An optional comparison
152+ * function, which takes two elements and returns int {-,0,+}, is accepted
153+ * as a second argument, but it is curently ignored.)
154+ *
155+ * @param a
156+ * An array of long
157+ *
158+ * @return A sorted copy of <em>a</em>
159+ */
160+ @ FunctionSpec (name = "matrixsum" , returnType = "array of array of int" , formalParameters = { "array of array of int" , "array of array of int" })
161+ public static long [][] matrixsum (final long [][] a , final long [][] b ) {
162+ double [][] a_double = new double [a .length ][];
163+ double [][] b_double = new double [b .length ][];
164+
165+ for (int i = 0 ; i < a .length ; i ++){
166+ a_double [i ] = Doubles .toArray (Longs .asList (a [i ]));
167+ }
168+
169+ for (int i = 0 ; i < b .length ; i ++){
170+ b_double [i ] = Doubles .toArray (Longs .asList (b [i ]));
171+ }
172+ Matrix a_matrix = new Matrix (a_double );
173+ Matrix b_matrix = new Matrix (b_double );
174+ double [][] result = a_matrix .plus (b_matrix ).getArray ();
175+ long [][]result_long = new long [result .length ][];
176+ for (int i = 0 ; i < result .length ; i ++){
177+ result_long [i ] = Longs .toArray (Doubles .asList (result [i ]));
178+ }
179+ return result_long ;
180+ }
181+
182+ /**
183+ * Returns the matrix version of an array. Only scalar values can be sorted.
184+ * Values will be arranged in increasing order. (An optional comparison
185+ * function, which takes two elements and returns int {-,0,+}, is accepted
186+ * as a second argument, but it is curently ignored.)
187+ *
188+ * @param a
189+ * An array of long
190+ *
191+ * @return A sorted copy of <em>a</em>
192+ */
193+ @ FunctionSpec (name = "matrixsubstract" , returnType = "array of array of int" , formalParameters = { "array of array of int" , "array of array of int" })
194+ public static long [][] matrixsubstract (final long [][] a , final long [][] b ) {
195+ double [][] a_double = new double [a .length ][];
196+ double [][] b_double = new double [b .length ][];
197+
198+ for (int i = 0 ; i < a .length ; i ++){
199+ a_double [i ] = Doubles .toArray (Longs .asList (a [i ]));
200+ }
201+
202+ for (int i = 0 ; i < b .length ; i ++){
203+ b_double [i ] = Doubles .toArray (Longs .asList (b [i ]));
204+ }
205+ Matrix a_matrix = new Matrix (a_double );
206+ Matrix b_matrix = new Matrix (b_double );
207+ double [][] result = a_matrix .minus (b_matrix ).getArray ();
208+ long [][]result_long = new long [result .length ][];
209+ for (int i = 0 ; i < result .length ; i ++){
210+ result_long [i ] = Longs .toArray (Doubles .asList (result [i ]));
211+ }
212+ return result_long ;
213+ }
214+
215+ /**
216+ * Returns the matrix version of an array. Only scalar values can be sorted.
217+ * Values will be arranged in increasing order. (An optional comparison
218+ * function, which takes two elements and returns int {-,0,+}, is accepted
219+ * as a second argument, but it is curently ignored.)
220+ *
221+ * @param a
222+ * An array of long
223+ *
224+ * @return A sorted copy of <em>a</em>
225+ */
226+ @ FunctionSpec (name = "multiply" , returnType = "array of array of int" , formalParameters = { "array of array of int" , "array of array of int" })
227+ public static double [][] multiply (final double [][] a , final double [][] b ) {
228+ Matrix a_matrix = new Matrix (a );
229+ Matrix b_matrix = new Matrix (b );
230+ return a_matrix .times (b_matrix ).getArray ();
231+ }
232+
233+ /**
234+ * Returns the matrix version of an array. Only scalar values can be sorted.
235+ * Values will be arranged in increasing order. (An optional comparison
236+ * function, which takes two elements and returns int {-,0,+}, is accepted
237+ * as a second argument, but it is curently ignored.)
238+ *
239+ * @param a
240+ * An array of long
241+ *
242+ * @return A sorted copy of <em>a</em>
243+ */
244+ @ FunctionSpec (name = "matrixsum" , returnType = "array of array of int" , formalParameters = { "array of array of int" , "array of array of int" })
245+ public static double [][] matrixsum (final double [][] a , final double [][] b ) {
246+ Matrix a_matrix = new Matrix (a );
247+ Matrix b_matrix = new Matrix (b );
248+ return a_matrix .plus (b_matrix ).getArray ();
249+ }
250+
251+ /**
252+ * Returns the matrix version of an array. Only scalar values can be sorted.
253+ * Values will be arranged in increasing order. (An optional comparison
254+ * function, which takes two elements and returns int {-,0,+}, is accepted
255+ * as a second argument, but it is curently ignored.)
256+ *
257+ * @param a
258+ * An array of long
259+ *
260+ * @return A sorted copy of <em>a</em>
261+ */
262+ @ FunctionSpec (name = "matrixsubstract" , returnType = "array of array of int" , formalParameters = { "array of array of int" , "array of array of int" })
263+ public static double [][] matrixsubstract (final double [][] a , final double [][] b ) {
264+ Matrix a_matrix = new Matrix (a );
265+ Matrix b_matrix = new Matrix (b );
266+ return a_matrix .minus (b_matrix ).getArray ();
267+ }
268+
269+
270+
114271 /**
115272 * Returns the matrix version of an array. Only scalar values can be sorted.
116273 * Values will be arranged in increasing order. (An optional comparison
0 commit comments