Skip to main content
Fix backticks after I learned how to do it.
Source Link
user202729
  • 502
  • 3
  • 11

Why can't Mathematica 9 compile this code?

x = {1};
Compile[{}, x[[1]]++;,
    {{x[[1]]++, _Integer}, {x[[1]], _Integer}}, CompilationTarget :> "C"][]

After printed message CompiledFunction::cflist, the value of x is (in my case) {2 + Compile``Variable$29510Compile`Variable$29510}. (only 1 backquote in code)

Searching this site for "Compile Increment" found Faster list duplicate 'limiter', where an Increment is used in Compile and run correctly. I tried to fix my code using Block:

Compile[{}, Block[{x}, x = {1}; x[[1]]++; x[[1]] ], CompilationTarget :> "C"][]

Those also work.

x = {1}; Compile[{}, x[[1]] += 1;, CompilationTarget :> "C"][]

(replace ++ by +=1) or

x = {1}; Compile[{}, x[[1]]++;][]

(remove CompilationTarget -> "C" part)

This seems like a bug. Is that fixed in Mathematica 10?

Why can't Mathematica 9 compile this code?

x = {1};
Compile[{}, x[[1]]++;,
    {{x[[1]]++, _Integer}, {x[[1]], _Integer}}, CompilationTarget :> "C"][]

After printed message CompiledFunction::cflist, the value of x is (in my case) {2 + Compile``Variable$29510}. (only 1 backquote in code)

Searching this site for "Compile Increment" found Faster list duplicate 'limiter', where an Increment is used in Compile and run correctly. I tried to fix my code using Block:

Compile[{}, Block[{x}, x = {1}; x[[1]]++; x[[1]] ], CompilationTarget :> "C"][]

Those also work.

x = {1}; Compile[{}, x[[1]] += 1;, CompilationTarget :> "C"][]

(replace ++ by +=1) or

x = {1}; Compile[{}, x[[1]]++;][]

(remove CompilationTarget -> "C" part)

This seems like a bug. Is that fixed in Mathematica 10?

Why can't Mathematica 9 compile this code?

x = {1};
Compile[{}, x[[1]]++;,
    {{x[[1]]++, _Integer}, {x[[1]], _Integer}}, CompilationTarget :> "C"][]

After printed message CompiledFunction::cflist, the value of x is (in my case) {2 + Compile`Variable$29510}.

Searching this site for "Compile Increment" found Faster list duplicate 'limiter', where an Increment is used in Compile and run correctly. I tried to fix my code using Block:

Compile[{}, Block[{x}, x = {1}; x[[1]]++; x[[1]] ], CompilationTarget :> "C"][]

Those also work.

x = {1}; Compile[{}, x[[1]] += 1;, CompilationTarget :> "C"][]

(replace ++ by +=1) or

x = {1}; Compile[{}, x[[1]]++;][]

(remove CompilationTarget -> "C" part)

This seems like a bug. Is that fixed in Mathematica 10?

replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

Why can't Mathematica 9 compile this code?

x = {1};
Compile[{}, x[[1]]++;,
    {{x[[1]]++, _Integer}, {x[[1]], _Integer}}, CompilationTarget :> "C"][]

After printed message CompiledFunction::cflist, the value of x is (in my case) {2 + Compile``Variable$29510}. (only 1 backquote in code)

Searching this site for "Compile Increment" found Faster list duplicate 'limiter'Faster list duplicate 'limiter', where an Increment is used in Compile and run correctly. I tried to fix my code using Block:

Compile[{}, Block[{x}, x = {1}; x[[1]]++; x[[1]] ], CompilationTarget :> "C"][]

Those also work.

x = {1}; Compile[{}, x[[1]] += 1;, CompilationTarget :> "C"][]

(replace ++ by +=1) or

x = {1}; Compile[{}, x[[1]]++;][]

(remove CompilationTarget -> "C" part)

This seems like a bug. Is that fixed in Mathematica 10?

Why can't Mathematica 9 compile this code?

x = {1};
Compile[{}, x[[1]]++;,
    {{x[[1]]++, _Integer}, {x[[1]], _Integer}}, CompilationTarget :> "C"][]

After printed message CompiledFunction::cflist, the value of x is (in my case) {2 + Compile``Variable$29510}. (only 1 backquote in code)

Searching this site for "Compile Increment" found Faster list duplicate 'limiter', where an Increment is used in Compile and run correctly. I tried to fix my code using Block:

Compile[{}, Block[{x}, x = {1}; x[[1]]++; x[[1]] ], CompilationTarget :> "C"][]

Those also work.

x = {1}; Compile[{}, x[[1]] += 1;, CompilationTarget :> "C"][]

(replace ++ by +=1) or

x = {1}; Compile[{}, x[[1]]++;][]

(remove CompilationTarget -> "C" part)

This seems like a bug. Is that fixed in Mathematica 10?

Why can't Mathematica 9 compile this code?

x = {1};
Compile[{}, x[[1]]++;,
    {{x[[1]]++, _Integer}, {x[[1]], _Integer}}, CompilationTarget :> "C"][]

After printed message CompiledFunction::cflist, the value of x is (in my case) {2 + Compile``Variable$29510}. (only 1 backquote in code)

Searching this site for "Compile Increment" found Faster list duplicate 'limiter', where an Increment is used in Compile and run correctly. I tried to fix my code using Block:

Compile[{}, Block[{x}, x = {1}; x[[1]]++; x[[1]] ], CompilationTarget :> "C"][]

Those also work.

x = {1}; Compile[{}, x[[1]] += 1;, CompilationTarget :> "C"][]

(replace ++ by +=1) or

x = {1}; Compile[{}, x[[1]]++;][]

(remove CompilationTarget -> "C" part)

This seems like a bug. Is that fixed in Mathematica 10?

Tweeted twitter.com/StackMma/status/765595735328980993
Source Link
user202729
  • 502
  • 3
  • 11

Mathematica 9 can't compile Increment Part with C

Why can't Mathematica 9 compile this code?

x = {1};
Compile[{}, x[[1]]++;,
    {{x[[1]]++, _Integer}, {x[[1]], _Integer}}, CompilationTarget :> "C"][]

After printed message CompiledFunction::cflist, the value of x is (in my case) {2 + Compile``Variable$29510}. (only 1 backquote in code)

Searching this site for "Compile Increment" found Faster list duplicate 'limiter', where an Increment is used in Compile and run correctly. I tried to fix my code using Block:

Compile[{}, Block[{x}, x = {1}; x[[1]]++; x[[1]] ], CompilationTarget :> "C"][]

Those also work.

x = {1}; Compile[{}, x[[1]] += 1;, CompilationTarget :> "C"][]

(replace ++ by +=1) or

x = {1}; Compile[{}, x[[1]]++;][]

(remove CompilationTarget -> "C" part)

This seems like a bug. Is that fixed in Mathematica 10?