Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am new to Mathematica and have a general question:

Working with matrices I have the impression that Compile can only be used if the elements of a matrix are ONLY Integers or ONLY Reals. No mixed types are allowed.

But my matrices generally include some missing elements like

m = {{1., 2.}, {Null, 3.}}

Is there a way to compile m*m ?

share|improve this question
Please note that matrix operations are in general very very fast in Mathematica without using Compile. In fact, it is easily possible that you slow something down. Try to use built-in functions first. Your observation about the types is correct. Compile can only handle tensors of one type.. either Real, Integer, ... but mixed types are not possible. The m you use is not even compilable! –  halirutan May 9 '14 at 22:51
@halirutan - thanks, your answer spared me a lot of trials and errors –  eldo May 10 '14 at 11:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.