Skip to main content
Post Merged (destination) from mathematica.stackexchange.com/questions/82790/…
Bounty Awarded with 100 reputation awarded by xyz
deleted 5 characters in body
Source Link
dr.blochwave
  • 8.8k
  • 3
  • 45
  • 78

Compile`InnerDo

This is the one that initially struck me as interesting since I use compiled functions quite a lot. From the documentation of Do:

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
      Module[{a}, a = x; Compile`InnerDo[a++, {i, 10^8}]]
     ]

f2 = Compile[{{x}},
      Module[{a}, a = x; Do[a++, {i, 10^8}]]
     ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here


Compile`Mod1

Seems to be just that, and is listable. In fact, if you write a compilable function that contains Mod[x, 1] then it gets compiled down to Compile`Mod1.

f1 = Compile[{{x}}, Compile`Mod1[x]];
f2 = Compile[{{x}}, Mod[x, 1]];

Needs["CompiledFunctionTools`"];
CompilePrint@f1 == CompilePrint@f2
(* True *)

Compile`DLLFunctionLoad / Compile`DLLLoad

These one seemsseem to perform the same functions as LibraryFunctionLoad:

fun1 = LibraryFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun2 = Compile`DLLFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun1[10] == fun2[10]
(* True *)

Compile`InnerDo

This is the one that initially struck me as interesting since I use compiled functions quite a lot. From the documentation of Do:

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
      Module[{a}, a = x; Compile`InnerDo[a++, {i, 10^8}]]
     ]

f2 = Compile[{{x}},
      Module[{a}, a = x; Do[a++, {i, 10^8}]]
     ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here


Compile`Mod1

Seems to be just that, and is listable. In fact, if you write a compilable function that contains Mod[x, 1] then it gets compiled down to Compile`Mod1.

f1 = Compile[{{x}}, Compile`Mod1[x]];
f2 = Compile[{{x}}, Mod[x, 1]];

Needs["CompiledFunctionTools`"];
CompilePrint@f1 == CompilePrint@f2
(* True *)

Compile`DLLFunctionLoad / Compile`DLLLoad

These one seems to perform the same functions as LibraryFunctionLoad:

fun1 = LibraryFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun2 = Compile`DLLFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun1[10] == fun2[10]
(* True *)

Compile`InnerDo

This is the one that initially struck me as interesting since I use compiled functions quite a lot. From the documentation of Do:

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
      Module[{a}, a = x; Compile`InnerDo[a++, {i, 10^8}]]
     ]

f2 = Compile[{{x}},
      Module[{a}, a = x; Do[a++, {i, 10^8}]]
     ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here


Compile`Mod1

Seems to be just that, and is listable. In fact, if you write a compilable function that contains Mod[x, 1] then it gets compiled down to Compile`Mod1.

f1 = Compile[{{x}}, Compile`Mod1[x]];
f2 = Compile[{{x}}, Mod[x, 1]];

Needs["CompiledFunctionTools`"];
CompilePrint@f1 == CompilePrint@f2
(* True *)

Compile`DLLFunctionLoad / Compile`DLLLoad

These seem to perform the same functions as LibraryFunctionLoad:

fun1 = LibraryFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun2 = Compile`DLLFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun1[10] == fun2[10]
(* True *)
Post Made Community Wiki by rm -rf
added 434 characters in body
Source Link
dr.blochwave
  • 8.8k
  • 3
  • 45
  • 78

Compile`InnerDo

This is the one that initially struck me as interesting since I use compiled functions quite a lot. From the documentation of Do,:

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
      Module[{a}, a = x; Compile`InnerDo[a++, {i, 10^8}]]
     ]

f2 = Compile[{{x}},
      Module[{a}, a = x; Do[a++, {i, 10^8}]]
     ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here


Compile`Mod1

Seems to be just that, and is listable. In fact, if you write a compilable function that contains Mod[x, 1] then it gets compiled down to Compile`Mod1.

f1 = Compile[{{x}}, Compile`Mod1[x]];
f2 = Compile[{{x}}, Mod[x, 1]];

Needs["CompiledFunctionTools`"];
CompilePrint@f1 == CompilePrint@f2
(* True *)

Compile`DLLFunctionLoad / Compile`DLLLoad

These one seems to perform the same functions as LibraryFunctionLoad:

fun1 = LibraryFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun2 = Compile`DLLFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun1[10] == fun2[10]
(* True *)

Compile`InnerDo

This struck me as interesting since I use compiled functions quite a lot. From the documentation of Do,

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
      Module[{a}, a = x; Compile`InnerDo[a++, {i, 10^8}]]
     ]

f2 = Compile[{{x}},
      Module[{a}, a = x; Do[a++, {i, 10^8}]]
     ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here


Compile`Mod1

Seems to be just that, and is listable. In fact, if you write a compilable function that contains Mod[x, 1] then it gets compiled down to Compile`Mod1.

f1 = Compile[{{x}}, Compile`Mod1[x]];
f2 = Compile[{{x}}, Mod[x, 1]];

Needs["CompiledFunctionTools`"];
CompilePrint@f1 == CompilePrint@f2
(* True *)

Compile`InnerDo

This is the one that initially struck me as interesting since I use compiled functions quite a lot. From the documentation of Do:

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
      Module[{a}, a = x; Compile`InnerDo[a++, {i, 10^8}]]
     ]

f2 = Compile[{{x}},
      Module[{a}, a = x; Do[a++, {i, 10^8}]]
     ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here


Compile`Mod1

Seems to be just that, and is listable. In fact, if you write a compilable function that contains Mod[x, 1] then it gets compiled down to Compile`Mod1.

f1 = Compile[{{x}}, Compile`Mod1[x]];
f2 = Compile[{{x}}, Mod[x, 1]];

Needs["CompiledFunctionTools`"];
CompilePrint@f1 == CompilePrint@f2
(* True *)

Compile`DLLFunctionLoad / Compile`DLLLoad

These one seems to perform the same functions as LibraryFunctionLoad:

fun1 = LibraryFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun2 = Compile`DLLFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
fun1[10] == fun2[10]
(* True *)
added compile mod1
Source Link
dr.blochwave
  • 8.8k
  • 3
  • 45
  • 78

Compile`InnerDo

The one thatThis struck me as interesting was Compile`InnerDo, since I use compiled functions quite a lot. From the documentation of Do,

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
      Module[{a},
   a = x;
   Compile`InnerDo[a++, {i, 10^8}]]]
   ]
  ]

f2 = Compile[{{x}},
      Module[{a},
   a = x;
   Do[a++, {i, 10^8}]]]
   ]
  ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here


Compile`Mod1

Seems to be just that, and is listable. In fact, if you write a compilable function that contains Mod[x, 1] then it gets compiled down to Compile`Mod1.

f1 = Compile[{{x}}, Compile`Mod1[x]];
f2 = Compile[{{x}}, Mod[x, 1]];

Needs["CompiledFunctionTools`"];
CompilePrint@f1 == CompilePrint@f2
(* True *)

The one that struck me as interesting was Compile`InnerDo, since I use compiled functions quite a lot. From the documentation of Do,

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
  Module[{a},
   a = x;
   Compile`InnerDo[a++, {i, 10^8}]
   ]
  ]

f2 = Compile[{{x}},
  Module[{a},
   a = x;
   Do[a++, {i, 10^8}]
   ]
  ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here

Compile`InnerDo

This struck me as interesting since I use compiled functions quite a lot. From the documentation of Do,

Unless an explicit Return is used, the value returned by Do is Null.

But that doesn't seem to be the case for Compile`InnerDo!

f1 = Compile[{{x}},
      Module[{a}, a = x; Compile`InnerDo[a++, {i, 10^8}]]
     ]

f2 = Compile[{{x}},
      Module[{a}, a = x; Do[a++, {i, 10^8}]]
     ]

f1[0] // AbsoluteTiming
(* 1.63 seconds, 99999999 *)

f2[0] // AbsoluteTiming
(* 1.63 seconds, Null *)

Essentially it adds an extra line into the result of CompilePrint:

enter image description here


Compile`Mod1

Seems to be just that, and is listable. In fact, if you write a compilable function that contains Mod[x, 1] then it gets compiled down to Compile`Mod1.

f1 = Compile[{{x}}, Compile`Mod1[x]];
f2 = Compile[{{x}}, Mod[x, 1]];

Needs["CompiledFunctionTools`"];
CompilePrint@f1 == CompilePrint@f2
(* True *)
added 155 characters in body
Source Link
dr.blochwave
  • 8.8k
  • 3
  • 45
  • 78
Loading
added 2 characters in body
Source Link
Kuba
  • 139k
  • 13
  • 298
  • 810
Loading
Source Link
dr.blochwave
  • 8.8k
  • 3
  • 45
  • 78
Loading