Kronecker product: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 2,879: | Line 2,879: | ||
<lang scala> object KroneckerProduct |
<lang scala> object KroneckerProduct |
||
{ |
{ |
||
/**Get the dimensions of the input matrix*/ |
|||
def getDimensions(matrix : Array[Array[Int]]) : (Int,Int) = { |
def getDimensions(matrix : Array[Array[Int]]) : (Int,Int) = { |
||
val dimensions = matrix.map(x => x.size) |
val dimensions = matrix.map(x => x.size) |
||
Line 2,885: | Line 2,885: | ||
} |
} |
||
/**Compute the Kronecker product between 2 input matrixes and return the result as a matrix*/ |
|||
def kroneckerProduct(matrix1 : Array[Array[Int]], matrix2 : Array[Array[Int]]) : Array[Array[Int]] = { |
def kroneckerProduct(matrix1 : Array[Array[Int]], matrix2 : Array[Array[Int]]) : Array[Array[Int]] = { |
||
val (r1,c1) = getDimensions(matrix1) |
val (r1,c1) = getDimensions(matrix1) |