# Promote\_op and preallocating result of linear operators

**URL:** <https://discourse.julialang.org/t/promote-op-and-preallocating-result-of-linear-operators/11332>\
**Category:** Internals & Design\
**Tags:** type, linearalgebra\
**Created:** [June 1, 2018, 11:44am UTC](https://discourse.julialang.org/t/promote-op-and-preallocating-result-of-linear-operators/11332 "2018-06-01T11:44:42Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![lostella](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lostella/32/356_2.png) [@lostella](https://discourse.julialang.org/u/lostella)\
**Post date:** [June 1, 2018, 8:09pm UTC](https://discourse.julialang.org/t/promote-op-and-preallocating-result-of-linear-operators/11332/5 "2018-06-01T20:09:17Z")

</div>

Thanks for clarifying.

My case may be simpler than what you described: I know that all elements in the result will have the same type. Just like for matrix-vector multiplication, each operand has all elements of the same type, and linear combinations of them should result in something according to how types are promoted when doing scalar `+` and `*` operations. That’s why the `promote_op` seemed like one way to go – until I read what people have to say about it.

Related topic: [Alternatives to `Base.promote_op(op, ::Type...)` for `op::Type`?](https://discourse.julialang.org/t/alternatives-to-base-promote-op-op-type-for-op-type/5289)

---

_[View the full topic](https://discourse.julialang.org/t/promote-op-and-preallocating-result-of-linear-operators/11332)._
