3 deleted 9 characters in body
source | link

We can construct this matrix directly as a SparseArray. This allows some classes of numerical matrices to be stored as packed arrays while being combined with symbolic or exact vectors (or vice versa), so there can be storage and run-time efficiency reasons for using a SparseArray, in addition to the obvious benefit of direct construction. On the other hand, the function needed to construct a sparse block matrix is undocumented.

Define:

f[A_?MatrixQ, t_?VectorQ] /; Last@Dimensions[A]Length[A] == Length[t] := 
 SparseArray`SparseBlockMatrix[{
  {1, 1} -> A, {1, 2} -> Transpose[{t}], {2, 2} -> {{1}}
 }, Dimensions[A] + 1];

Now:

f[IdentityMatrix[5], Array[a, 5]]

gives (as a sparse array; if you want exactly this output you must first use Normal):

matrix resulting from the given input

We can construct this matrix directly as a SparseArray. This allows some classes of numerical matrices to be stored as packed arrays while being combined with symbolic or exact vectors (or vice versa), so there can be storage and run-time efficiency reasons for using a SparseArray, in addition to the obvious benefit of direct construction. On the other hand, the function needed to construct a sparse block matrix is undocumented.

Define:

f[A_?MatrixQ, t_?VectorQ] /; Last@Dimensions[A] == Length[t] := 
 SparseArray`SparseBlockMatrix[{
  {1, 1} -> A, {1, 2} -> Transpose[{t}], {2, 2} -> {{1}}
 }, Dimensions[A] + 1];

Now:

f[IdentityMatrix[5], Array[a, 5]]

gives (as a sparse array; if you want exactly this output you must first use Normal):

matrix resulting from the given input

We can construct this matrix directly as a SparseArray. This allows some classes of numerical matrices to be stored as packed arrays while being combined with symbolic or exact vectors (or vice versa), so there can be storage and run-time efficiency reasons for using a SparseArray, in addition to the obvious benefit of direct construction. On the other hand, the function needed to construct a sparse block matrix is undocumented.

Define:

f[A_?MatrixQ, t_?VectorQ] /; Length[A] == Length[t] := 
 SparseArray`SparseBlockMatrix[{
  {1, 1} -> A, {1, 2} -> Transpose[{t}], {2, 2} -> {{1}}
 }, Dimensions[A] + 1];

Now:

f[IdentityMatrix[5], Array[a, 5]]

gives (as a sparse array; if you want exactly this output you must first use Normal):

matrix resulting from the given input

2 Being too glib about undocumented functions seems to have earned me a downvote, so I edited the answer to better motivate this solution.
source | link

Let's try usingWe can construct this matrix directly as a SparseArray. This allows some classes of numerical matrices to be stored as packed arrays while being combined with symbolic or exact vectors (or vice versa), so there can be storage and run-time efficiency reasons for using a SparseArray, in addition to the obvious benefit of direct construction. On the other hand, the function needed to construct a sparse block matrix is undocumented functions.

Define:

f[A_?MatrixQ, t_?VectorQ] /; Length[A]Last@Dimensions[A] == Length[t] := 
 SparseArray`SparseBlockMatrix[{
  {1, 1} -> A, {1, 2} -> Transpose[{t}], {Length[A] + 12, 2} -> {{1}}
 }];, Dimensions[A] + 1];

Now:

f[IdentityMatrix[5], Array[a, 5]]

gives (as a sparse array; if you want exactly this output you must first use Normal):

matrix resulting from the given input

Let's try using some undocumented functions.

Define:

f[A_?MatrixQ, t_?VectorQ] /; Length[A] == Length[t] := 
 SparseArray`SparseBlockMatrix[{
  {1, 1} -> A, {1, 2} -> Transpose[{t}], {Length[A] + 1, 2} -> {{1}}
 }];

Now:

f[IdentityMatrix[5], Array[a, 5]]

gives (as a sparse array; if you want exactly this output you must first use Normal):

matrix resulting from the given input

We can construct this matrix directly as a SparseArray. This allows some classes of numerical matrices to be stored as packed arrays while being combined with symbolic or exact vectors (or vice versa), so there can be storage and run-time efficiency reasons for using a SparseArray, in addition to the obvious benefit of direct construction. On the other hand, the function needed to construct a sparse block matrix is undocumented.

Define:

f[A_?MatrixQ, t_?VectorQ] /; Last@Dimensions[A] == Length[t] := 
 SparseArray`SparseBlockMatrix[{
  {1, 1} -> A, {1, 2} -> Transpose[{t}], {2, 2} -> {{1}}
 }, Dimensions[A] + 1];

Now:

f[IdentityMatrix[5], Array[a, 5]]

gives (as a sparse array; if you want exactly this output you must first use Normal):

matrix resulting from the given input

1
source | link

Let's try using some undocumented functions.

Define:

f[A_?MatrixQ, t_?VectorQ] /; Length[A] == Length[t] := 
 SparseArray`SparseBlockMatrix[{
  {1, 1} -> A, {1, 2} -> Transpose[{t}], {Length[A] + 1, 2} -> {{1}}
 }];

Now:

f[IdentityMatrix[5], Array[a, 5]]

gives (as a sparse array; if you want exactly this output you must first use Normal):

matrix resulting from the given input