1
$\begingroup$

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 ?

$\endgroup$
  • 1
    $\begingroup$ 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! $\endgroup$ – halirutan May 9 '14 at 22:51
  • $\begingroup$ @halirutan - thanks, your answer spared me a lot of trials and errors $\endgroup$ – eldo May 10 '14 at 11:22
2
$\begingroup$

Quoting a comment by halirutan,

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 (a reference is here). The m you use is not even compilable!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.