Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
1  
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

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!

share|improve this answer

Your Answer

 
discard

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

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