## digitalmars.D.learn - Is this an okay representation of a dynamically sized Matrix, to be

```Code:
----
module matrix;

import std.array;

struct Matrix(E)
{
private:
E[][];

this() {
}

void deleteRow(int i)
{
E = E[0..i] ~ E[i..\$];
}

void deleteColumn(int j)
{
for (int i=0; i < E.length; i++)
{
E[i] = E[i][0..j] ~ E[i][j..\$];
}
}

void insertRow(int i, E[] row)
{
if (E.length != 0)
assert(E.length == row.length);
E.insertInPlace(i, row);
}

void insertColumn(int j, E[] col)
{
for (int i=0; i < E.length; i++)
{
E[i].insertInPlace(j, col[i]);
}
}

int numRows() { return E.length; }

int numColumns() {
if (E.length == 0)
return 0;
return E.length;
}

}

Is there a more efficient way of doing this, knowing that I'll be
inserting columns / rows every time we need to create a new
hidden state so this matrix will be huge, for a good model.  By
huge we'll probably use the full capacity of a long[] in D.  I've
already tried doing this in MQL5 and we exceeded easily the max
array capacity.
```
Dec 27 2017
```On Thursday, 28 December 2017 at 01:34:10 UTC, Enjoys Math wrote:
Code:
----
module matrix;

import std.array;

struct Matrix(E)
{
private:
E[][];

this() {
}

void deleteRow(int i)
{
E = E[0..i] ~ E[i..\$];
}

void deleteColumn(int j)
{
for (int i=0; i < E.length; i++)
{
E[i] = E[i][0..j] ~ E[i][j..\$];
}
}

void insertRow(int i, E[] row)
{
if (E.length != 0)
assert(E.length == row.length);
E.insertInPlace(i, row);
}

void insertColumn(int j, E[] col)
{
for (int i=0; i < E.length; i++)
{
E[i].insertInPlace(j, col[i]);
}
}

int numRows() { return E.length; }

int numColumns() {
if (E.length == 0)
return 0;
return E.length;
}

}

Is there a more efficient way of doing this, knowing that I'll
be inserting columns / rows every time we need to create a new
hidden state so this matrix will be huge, for a good model.  By
huge we'll probably use the full capacity of a long[] in D.
I've already tried doing this in MQL5 and we exceeded easily
the max array capacity.

Full capacity of a long[] (or any array) is the entire
addressable memory, which is 4GB for 32bit. You will not exceed