Re: Performance improvement needed - Help.
- To: mathgroup at smc.vnet.net
- Subject: [mg63575] Re: [mg63552] Performance improvement needed - Help.
- From: Pratik Desai <pdesai1 at umbc.edu>
- Date: Fri, 6 Jan 2006 05:24:19 -0500 (EST)
- References: <200601050812.DAA19819@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Tonybony wrote: >Hello, >I am trying to improve the performance of a bottle neck operation. I've >used functional programming and read about Packed Arrays. My current >operation is: > >Efunc[k_, x_, y_, z_] := Radialf[k, VNmax, x, y,z].Map[(MMatrix[[# - >Nmin + 1]].SphericalHarmonicY[#, Range[-#, #],Theta[x, y, z], Phi[x, >y]]) &, VNmax, {1}]; > >EMatrix= Apply[Efunc[k, #1, #2, 0.0] &, Grid, {2}]; > >Where I defined, >GridX = Range[Xini, Xfin, Xinc]; >Grid = Outer[List, GridX, GridX]; >VNmax = Range[Nmin, Nmax]; >GridG = Table[{n, m}, {n, Nmin, Nmax}, {m, -n, n}]; >Radial[k_, n_, x_, y_, z_] := BesselJ[n,k Sqrt[x^2+y^2+z^2]]; >MMatrix= Apply[(Exp[-#2 fio] MAmpl[[#1 - Nmin + 1, Abs[#2] + 1]] >MI1[[#1 - Nmin + 1, Abs[#2] + 1]] Cosfio) &, GridG, {2}]; > >I have tried the command, >GridG = Developer`ToPackedArray[Table[{n, m}, {n, Nmin, Nmax}, {m, -n, >n}]]; >To see if I could build a packed array so that I could better >performance, but didn't succeed. Maybe I am creating a wrong array, but >I don't know of any alternative. > > I think that might be the problem, based on the documentation I have seen PackedArray seems to work only for rectangular tensors (whatever that means) http://documents.wolfram.com/mathematica/Built-inFunctions/AdvancedDocumentation/LinearAlgebra/LinearAlgebraInMathematica/Performance/PackedArrays/AdvancedDocumentationLinearAlgebra5.0.0.html When I tried the array provided by you in GridG, I get the following Clear[GridG, data] Nmin = 0; Nmax = 10; data1 = Table[{n, m}, {n, Nmin, Nmax}, {m, -n, n}]; data1 // MatrixQ; >>False Hence PackedArray does not seem to work Hope this helps Praik >For each element of GridG I have a pair of point (x,y) that I pass >along a set of function for calculations. Is their an efficient way of >doing this? > >Thanks, >Antonio > > >
- References:
- Performance improvement needed - Help.
- From: "Tonybony" <aneves@gmail.com>
- Performance improvement needed - Help.