# Question:How to resolve a matrix of matrices?

## Question:How to resolve a matrix of matrices?

Maple 2015

I want to create a matrix (B) from entries of other matrices (A) with a helper-function (helper). The helper function is defined such that it returns a certain matrix depending on the index variables. This is necessary because the inner matrices are constructed with another function.

Since the helper-function returns matrices, the big matrix is of datatype=matrix. Unfortunately, creating the big matrix with the correct size and forcing the datatype=float, does not yield the desired result. However, the manual definition using the constructor with a list of matrices does create the desired matrix.

How do I resolve a matrix of matrices?

Note: I know that I could write a convert function that copies the entries to a corresponding matrix, though this seems to be unnecessary effort to me.

This might not be minimal but shows the issue. (Compare and )

MWE_matrix_of_matrices.mw

 > restart; with(LinearAlgebra):
 > size_A := 2; size_B := 3;
 (1)
 > helper2 := proc(i::integer,j::integer);   if i=j then     a;   elif i=j-1 or i=j+1 then     b;   else     c;   end if; end proc: helper3 := proc(i::integer,j::integer);   if i=j then     Matrix(size_A,size_A,helper2);   elif i=j-1 or i=j+1 then     -IdentityMatrix(size_A);   else     Matrix(size_A);   end if; end proc: A := Matrix(size_A, size_A, helper2); B := Matrix(size_B, size_B, helper3); B := Matrix(size_B,size_B, helper3, datatype = float); B := Matrix(size_B*size_A, size_B*size_A,[Matrix(size_B,size_B,helper3)], datatype = float)
 > test := Matrix(4, 4, [                 [Matrix([[1,2],[0,9]]), Matrix([[3,6],[0,9]])],                 [Matrix([[3,4],[7,8]]), Matrix([[7,6],[5,5]])]                ]); # is converted to a matrix of floats
 (2)

﻿