# ArrayFlatten::intnm: Non-negative machine-sized integer expected

**URL:** <https://community.wolfram.com/t/arrayflatten-non-negative-machine-sized-integer-expected/20476>\
**Category:** Questions\
**Created:** [August 1, 2022, 10:21am UTC](https://community.wolfram.com/t/arrayflatten-non-negative-machine-sized-integer-expected/20476 "2022-08-01T10:21:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hongyizhao](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@hongyizhao](https://community.wolfram.com/u/hongyizhao)\
**Post date:** [August 1, 2022, 10:21am UTC](https://community.wolfram.com/t/arrayflatten-non-negative-machine-sized-integer-expected/20476/1 "2022-08-01T10:21:57Z")

</div>

See my following code snippet:

```
In[122]:= AA = {Inverse[R1] . R . R1, -Inverse[R1] . s1 + 
   Inverse[R1] . (t + R . s1)}
AA /. {Dot -> Times, R1 -> {{1}}} // ArrayFlatten[#, {2}] &

Out[122]= {Inverse[R1] . R . R1, -Inverse[R1] . s1 + 
  Inverse[R1] . (t + R . s1)}

During evaluation of In[122]:= ArrayFlatten::intnm: Non-negative machine-sized integer expected at position 2 in ArrayFlatten[{{{R}},{{-s1+R s1+t}}},{2}].

Out[123]= ArrayFlatten[{{{R}}, {{-s1 + R s1 + t}}}, {2}]

```

I want to obtain the following form:

```
{R, (-1 + R) s + t}

```

Any hints will be appreciated.

Regards,  
Zhao

---

<div class="post-metadata">

**Author:** ![hansmilton](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hansmilton/32/8656_2.png) [@hansmilton](https://community.wolfram.com/u/hansmilton)\
**Post date:** [August 1, 2022, 11:44am UTC](https://community.wolfram.com/t/arrayflatten-non-negative-machine-sized-integer-expected/20476/2 "2022-08-01T11:44:25Z")

</div>

A simple `Flatten` will give what you want

```
AA = {Inverse[R1] . R . R1, -Inverse[R1] . s1 + Inverse[R1] . (t + R . s1)}
AA /. {Dot -> Times, R1 -> {{1}}} // Flatten // Simplify

```

---

<div class="post-metadata">

**Author:** ![hongyizhao](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@hongyizhao](https://community.wolfram.com/u/hongyizhao)\
**Post date:** [August 1, 2022, 1:12pm UTC](https://community.wolfram.com/t/arrayflatten-non-negative-machine-sized-integer-expected/20476/3 "2022-08-01T13:12:24Z")

</div>

Thank you. It works.

If, here, **R** is a 3 by 3 invertible matrix, **s1** and **t** are 3 by 1 column vectors. I want to do the following rule replace:

```
AA/. {R1 -> IdentityMatrix[3]} // Flatten // Simplify

```

What I want to get is the following:

```
{R, (-IdentityMatrix[3] + R) . s1 + t}

```

But the following result is returned:

```
{{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} . 
  R . {{1, 0, 0}, {0, 1, 0}, {0, 0, 
    1}}, -{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} . 
    s1 + {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} . (t + R . s1)}

```

Is there any way to solve this problem?

Regards,  
Zhao
