Re: Mixed tensors as arguments of compiled functions
- To: mathgroup at smc.vnet.net
- Subject: [mg66799] Re: Mixed tensors as arguments of compiled functions
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Tue, 30 May 2006 05:49:34 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 5/29/06 at 6:05 AM, bilotta78 at hotpop.com (Giuseppe Bilotta) wrote: >I am trying to thoroughly optimize my code, and was now looking into >compiled functions. A problem I have is that some of the structures >I need to manipulate are matrices of the form {{_Integer,_Real}..}), >but Mathematica only allows me to specify tensors whose elements are >all of the same type. Is there a way to work around this limitation? It simply isn't true Mathematica only allows matrices to be defined with a single type. For example here is a matrix having the form {{_Integer, _Real} ... } a = Table[{n, Random[]}, {n, 5}]; and this can easily be manipulated with say In[14]:= a^2 Out[14]//InputForm= {{1, 0.777778}, {4, 0.488225}, {9, 0.522976}, {16, 0.509629}, {25, 0.948508}} However, several things used by Mathematica to enhance performance will not be in effect with arrays of mixed type elements. For example Mathematica does not use packed arrays with arrays of the form {{_Integer,_Real} ...}. The only way to be able to take advantage of those performance enhancements would be to separate the various types. For an array with this particular structure, defining two new variables, i.e., c = a[[All,1]]; d = a[[All,2]]; should effective usage of packed arrays, Compile etc. -- To reply via email subtract one hundred and four