Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.apache.mahout.math;
 
 
 import java.util.Map;

The basic interface including numerous convenience functions
 
 public interface Matrix extends CloneableVectorIterable {

  

Returns:
a formatted String suitable for output
 
   String asFormatString();

  
Assign the value to all elements of the receiver

Parameters:
value a double value
Returns:
the modified receiver
 
   Matrix assign(double value);

  
Assign the values to the receiver

Parameters:
values a double[] of values
Returns:
the modified receiver
Throws:
CardinalityException if the cardinalities differ
 
   Matrix assign(double[][] values);

  
Assign the other vector values to the receiver

Parameters:
other a Matrix
Returns:
the modified receiver
Throws:
CardinalityException if the cardinalities differ
 
   Matrix assign(Matrix other);

  
Apply the function to each element of the receiver

Parameters:
function a DoubleFunction to apply
Returns:
the modified receiver
 
   Matrix assign(DoubleFunction function);

  
Apply the function to each element of the receiver and the corresponding element of the other argument

Parameters:
other a Matrix containing the second arguments to the function
function a DoubleDoubleFunction to apply
Returns:
the modified receiver
Throws:
CardinalityException if the cardinalities differ
 
   Matrix assign(Matrix otherDoubleDoubleFunction function);

  
Assign the other vector values to the column of the receiver

Parameters:
column the int row to assign
other a Vector
Returns:
the modified receiver
Throws:
CardinalityException if the cardinalities differ
 
   Matrix assignColumn(int columnVector other);

  
Assign the other vector values to the row of the receiver

Parameters:
row the int row to assign
other a Vector
Returns:
the modified receiver
Throws:
CardinalityException if the cardinalities differ
 
   Matrix assignRow(int rowVector other);

  
Collects the results of a function applied to each row of a matrix.

Parameters:
f The function to be applied to each row.
Returns:
The vector of results.
Collects the results of a function applied to each column of a matrix.

Parameters:
f The function to be applied to each column.
Returns:
The vector of results.
Collects the results of a function applied to each element of a matrix and then aggregated.

Parameters:
combiner A function that combines the results of the mapper.
mapper A function to apply to each element.
Returns:
The result.
  double aggregate(DoubleDoubleFunction combinerDoubleFunction mapper);

  

Returns:
The number of rows in the matrix.
  int columnSize();

  

Returns:
Returns the number of rows in the matrix.
  int rowSize();

  
Return a copy of the recipient

Returns:
a new Matrix
  Matrix clone();

  
Returns matrix determinator using Laplace theorem

Returns:
a matrix determinator
  double determinant();

  
Return a new matrix containing the values of the recipient divided by the argument

Parameters:
x a double value
Returns:
a new Matrix
  Matrix divide(double x);

  
Return the value at the given indexes

Parameters:
row an int row index
column an int column index
Returns:
the double at the index
Throws:
IndexException if the index is out of bounds
  double get(int rowint column);

  
Return the value at the given indexes, without checking bounds

Parameters:
row an int row index
column an int column index
Returns:
the double at the index
  double getQuick(int rowint column);

  
Return an empty matrix of the same underlying class as the receiver

Returns:
a Matrix
  Matrix like();

  
Returns an empty matrix of the same underlying class as the receiver and of the specified size.

Parameters:
rows the int number of rows
columns the int number of columns
  Matrix like(int rowsint columns);

  
Return a new matrix containing the element by element difference of the recipient and the argument

Parameters:
x a Matrix
Returns:
a new Matrix
Throws:
CardinalityException if the cardinalities differ
  Matrix minus(Matrix x);

  
Return a new matrix containing the sum of each value of the recipient and the argument

Parameters:
x a double
Returns:
a new Matrix
  Matrix plus(double x);

  
Return a new matrix containing the element by element sum of the recipient and the argument

Parameters:
x a Matrix
Returns:
a new Matrix
Throws:
CardinalityException if the cardinalities differ
  Matrix plus(Matrix x);

  
Set the value at the given index

Parameters:
row an int row index into the receiver
column an int column index into the receiver
value a double value to set
Throws:
IndexException if the index is out of bounds
  void set(int rowint columndouble value);
  void set(int rowdouble[] data);

  
Set the value at the given index, without checking bounds

Parameters:
row an int row index into the receiver
column an int column index into the receiver
value a double value to set
  void setQuick(int rowint columndouble value);

  
Return the number of values in the recipient

Returns:
an int[2] containing [row, column] count
  int[] getNumNondefaultElements();

  
Return a new matrix containing the product of each value of the recipient and the argument

Parameters:
x a double argument
Returns:
a new Matrix
  Matrix times(double x);

  
Return a new matrix containing the product of the recipient and the argument

Parameters:
x a Matrix argument
Returns:
a new Matrix
Throws:
CardinalityException if the cardinalities are incompatible
  Matrix times(Matrix x);

  
Return a new matrix that is the transpose of the receiver

Returns:
the transpose
  Matrix transpose();

  
Return the sum of all the elements of the receiver

Returns:
a double
  double zSum();

  
Return a map of the current column label bindings of the receiver

Returns:
a Map<String, Integer>
Return a map of the current row label bindings of the receiver

Returns:
a Map<String, Integer>
Sets a map of column label bindings in the receiver

Parameters:
bindings a Map<String, Integer> of label bindings
  void setColumnLabelBindings(Map<StringIntegerbindings);

  
Sets a map of row label bindings in the receiver

Parameters:
bindings a Map<String, Integer> of label bindings
  void setRowLabelBindings(Map<StringIntegerbindings);

  
Return the value at the given labels

Parameters:
rowLabel a String row label
columnLabel a String column label
Returns:
the double at the index
Throws:
IndexException if the index is out of bounds
  double get(String rowLabelString columnLabel);

  
Set the value at the given index

Parameters:
rowLabel a String row label
columnLabel a String column label
value a double value to set
Throws:
IndexException if the index is out of bounds
  void set(String rowLabelString columnLabeldouble value);

  
Set the value at the given index, updating the row and column label bindings

Parameters:
rowLabel a String row label
columnLabel a String column label
row an int row index
column an int column index
value a double value
  void set(String rowLabelString columnLabelint rowint columndouble value);

  
Sets the row values at the given row label

Parameters:
rowLabel a String row label
rowData a double[] array of row data
  void set(String rowLabeldouble[] rowData);

  
Sets the row values at the given row index and updates the row labels

Parameters:
rowLabel the String row label
row an int the row index
rowData a double[] array of row data
  void set(String rowLabelint rowdouble[] rowData);
  /*
   * Need stories for these but keeping them here for now.
   * 
   */
  // void getNonZeros(IntArrayList jx, DoubleArrayList values);
  // void foreachNonZero(IntDoubleFunction f);
  // double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map);
  // double aggregate(Matrix other, DoubleDoubleFunction aggregator,
  // DoubleDoubleFunction map);
  // NewMatrix assign(Matrix y, DoubleDoubleFunction function, IntArrayList
  // nonZeroIndexes);

  
Return a view into part of a matrix. Changes to the view will change the original matrix.

Parameters:
offset an int[2] offset into the receiver
size the int[2] size of the desired result
Returns:
a matrix that shares storage with part of the original matrix.
Throws:
CardinalityException if the length is greater than the cardinality of the receiver
IndexException if the offset is negative or the offset+length is outside of the receiver
  Matrix viewPart(int[] offsetint[] size);

  
Return a view into part of a matrix. Changes to the view will change the original matrix.

Parameters:
rowOffset The first row of the view
rowsRequested The number of rows in the view
columnOffset The first column in the view
columnsRequested The number of columns in the view
Returns:
a matrix that shares storage with part of the original matrix.
Throws:
CardinalityException if the length is greater than the cardinality of the receiver
IndexException if the offset is negative or the offset+length is outside of the receiver
  Matrix viewPart(int rowOffsetint rowsRequestedint columnOffsetint columnsRequested);

  
Return a reference to a row. Changes to the view will change the original matrix.

Parameters:
row The index of the row to return.
Returns:
A vector that shares storage with the original.
  Vector viewRow(int row);

  
Return a reference to a column. Changes to the view will change the original matrix.

Parameters:
column The index of the column to return.
Returns:
A vector that shares storage with the original.
  Vector viewColumn(int column);

  
Returns a reference to the diagonal of a matrix. Changes to the view will change the original matrix.

Returns:
A vector that shares storage with the original matrix.
New to GrepCode? Check out our FAQ X