MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Compile problem: Mathematica 4

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18864] Re: Compile problem: Mathematica 4
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Sun, 25 Jul 1999 03:30:04 -0400
  • Organization: University of Western Australia
  • References: <7n13ce$be7@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Paul Howland wrote:

> What is wrong with the following (simplified) compile statement?  It seems
> that the Compiler doesn't recognise that Round[] returns an object with a
> Head of Integer.  Can I explicitly tell the compiler that this is the case?
>
> Code follows:
>
> In[4]:=
> f=Compile[{{x, _Real,1}}, i=Round[2.3]; x[[i]]++;Return[x]]

No problem with compiling in version 4 -- but you cannot modify x this way.

Notebook[{
Cell[BoxData[
    \(TraditionalForm\`\(f =
        Compile[{{x, _Real, 1}}, i = Round[2.3]; \ \(x[\([i]\)]++\);
          Return[x]];\)\)], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    \(TraditionalForm\`f[{1, 2, 3}]\)], "Input"],

Cell[BoxData[
    FormBox[
      RowBox[{\(Set::"setps"\), \(\(:\)\(\ \)\), \
"\<\"\\!\\(TraditionalForm\\`\\({1.`, 2.`, 3.`}\\)\\) in assignment of part \
is not a symbol.\"\>"}], TraditionalForm]], "Message"],

Cell[BoxData[
    \(TraditionalForm\`{1.`, 2.`, 3.`}\)], "Output"]
}, Open  ]],

Cell[BoxData[
    FormBox[
      RowBox[{
        RowBox[{"f", "=",
          RowBox[{"Compile", "[",
            RowBox[{
              RowBox[{"(", "\[NoBreak]", GridBox[{
                    {"x", "_Real", "1"}
                    }], "\[NoBreak]", ")"}],
              ",", \(Module[{y = x,
                  i = Round(2.3)}, \(y\[LeftDoubleBracket]
                    i\[RightDoubleBracket]++\); Return[y]]\)}], "]"}]}],
        ";"}], TraditionalForm]], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    \(TraditionalForm\`f[{1, 2, 3}]\)], "Input"],

Cell[BoxData[
    \(TraditionalForm\`{1.`, 3.`, 3.`}\)], "Output"]
}, Open  ]]
}
]


____________________________________________________________________
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia
Nedlands WA  6907                     mailto:paul at physics.uwa.edu.au
AUSTRALIA                            http://physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________




  • Prev by Date: Re: ? Repeated Patterns ?
  • Next by Date: Re: implcit plot with undefined expression
  • Previous by thread: Re: Compile problem: Mathematica 4
  • Next by thread: Re: Compile problem: Mathematica 4