# View for hcat(A,b)?

**URL:** https://discourse.julialang.org/t/view-for-hcat-a-b/74211
**Category:** New to Julia
**Tags:** linearalgebra
**Created:** [January 7, 2022, 7:42pm UTC](https://discourse.julialang.org/t/view-for-hcat-a-b/74211 "2022-01-07T19:42:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)
#### Post date: [January 7, 2022, 7:42pm UTC](https://discourse.julialang.org/t/view-for-hcat-a-b/74211/1 "2022-01-07T19:42:10Z")

</div>

Hi,  
some algs like Gaussian elimination or reduced echelon form work on the structure `Ab = [A, b]`.  
Is there a way to pass `A` and `b`, then work on `Ab` without allocations, a kind of `view()`?

---

<div class="post-metadata">

### Author: ![zsoerenm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zsoerenm/32/664_2.png) [@zsoerenm](https://discourse.julialang.org/u/zsoerenm)
#### Post date: [January 7, 2022, 9:59pm UTC](https://discourse.julialang.org/t/view-for-hcat-a-b/74211/2 "2022-01-07T21:59:10Z")

</div>

Are you looking for an allocation free hcat?  
If yes, have a look at LazyArrays.jl:  
[https://github.com/JuliaArrays/LazyArrays.jl#concatenation](https://github.com/JuliaArrays/LazyArrays.jl#concatenation)

---

<div class="post-metadata">

### Author: ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)
#### Post date: [January 7, 2022, 10:10pm UTC](https://discourse.julialang.org/t/view-for-hcat-a-b/74211/3 "2022-01-07T22:10:08Z")

</div>

good find - thx!

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [January 7, 2022, 11:08pm UTC](https://discourse.julialang.org/t/view-for-hcat-a-b/74211/4 "2022-01-07T23:08:00Z")

</div>

> [@Bardo](#):
>
> some algs like Gaussian elimination or reduced echelon form work on the structure `Ab = [A, b]`

Note that this is more common in hand calculation than in serious numerics. In practical numerical algorithms, you can generally analyze `A` first and then `b` subsequently.

For example, the analogue of Gaussian elimination on `[A b]` is to do LU factorization of `A` and then apply the factorization to `b` with triangular solves. (Julia provides easy, efficient methods for this.) Similarly for other factorization. (Reduced echelon form is not really used in practical numerics.)

---

<div class="post-metadata">

### Author: ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)
#### Post date: [January 8, 2022, 8:00am UTC](https://discourse.julialang.org/t/view-for-hcat-a-b/74211/5 "2022-01-08T08:00:58Z")

</div>

> [@stevengj](#):
>
> Note that this is more common in hand calculation than in serious numerics. In practical numerical algorithms, you can generally analyze `A` first and then `b` subsequently.

No doubt for usual numerical work.

My special use case is code generation which actually resembles hand calculation.

Similar for the reduced row echelon form, used to convert MNA matrices from circuit simulation to state-space form.

Since GE does not explicitly calculate and store `L`, it is faster than `LU` for a single RHS.  
I was still looking for an implementation of GE which works on `A, b` instead of `[A b]`.  
Found it here: [https://ww2.odu.edu/~agodunov/computing/programs/book2/Ch06/Gauss\_2.f90](https://ww2.odu.edu/~agodunov/computing/programs/book2/Ch06/Gauss_2.f90)
