mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-18 12:03:40 +01:00
Fix leadz
This commit is contained in:
parent
ed374af81f
commit
3c77e8267d
@ -10,14 +10,14 @@ Requirements
|
|||||||
|
|
||||||
* BLAS/LAPACK : Linear algebra
|
* BLAS/LAPACK : Linear algebra
|
||||||
* LaCaml : LAPACK OCaml interface
|
* LaCaml : LAPACK OCaml interface
|
||||||
|
* gmp : GNU Multiple Precision arithmetic library
|
||||||
* Zarith : Arbitrary-precision integers
|
* Zarith : Arbitrary-precision integers
|
||||||
* GetOpt : Parsing of command-line
|
* GetOpt : Parsing of command-line
|
||||||
* gmp : GNU Multiple Precision arithmetic library
|
|
||||||
* odoc-ltxhtml : https://github.com/akabe/odoc-ltxhtml
|
|
||||||
* Alcotest : Lightweight testing framework
|
* Alcotest : Lightweight testing framework
|
||||||
|
* odoc-ltxhtml : https://github.com/akabe/odoc-ltxhtml
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
opam install dune lacaml getopt alcotest zarith
|
opam install dune lacaml getopt alcotest zarith camlp-streams
|
||||||
```
|
```
|
||||||
|
|
||||||
To use the Intel MKL library:
|
To use the Intel MKL library:
|
||||||
|
@ -73,12 +73,12 @@ CAMLprim value popcnt_bytecode(value i) {
|
|||||||
|
|
||||||
/* [[file:~/QCaml/common/util.org::*Trailz][Trailz:1]] */
|
/* [[file:~/QCaml/common/util.org::*Trailz][Trailz:1]] */
|
||||||
CAMLprim int32_t trailz(int64_t i) {
|
CAMLprim int32_t trailz(int64_t i) {
|
||||||
return __builtin_ctzll (i);
|
return i == 0L ? 64 : __builtin_ctzll (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CAMLprim value trailz_bytecode(value i) {
|
CAMLprim value trailz_bytecode(value i) {
|
||||||
return caml_copy_int32(__builtin_ctzll (Int64_val(i)));
|
return caml_copy_int32(i == 0L ? 64 : __builtin_ctzll (Int64_val(i)));
|
||||||
}
|
}
|
||||||
/* Trailz:1 ends here */
|
/* Trailz:1 ends here */
|
||||||
|
|
||||||
@ -87,11 +87,11 @@ CAMLprim value trailz_bytecode(value i) {
|
|||||||
|
|
||||||
/* [[file:~/QCaml/common/util.org::*Leadz][Leadz:1]] */
|
/* [[file:~/QCaml/common/util.org::*Leadz][Leadz:1]] */
|
||||||
CAMLprim int32_t leadz(int64_t i) {
|
CAMLprim int32_t leadz(int64_t i) {
|
||||||
return __builtin_clzll(i);
|
return i == 0L ? 64 : __builtin_clzll(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CAMLprim value leadz_bytecode(value i) {
|
CAMLprim value leadz_bytecode(value i) {
|
||||||
return caml_copy_int32(__builtin_clzll (Int64_val(i)));
|
return caml_copy_int32(i == 0L ? 64 : __builtin_clzll (Int64_val(i)));
|
||||||
}
|
}
|
||||||
/* Leadz:1 ends here */
|
/* Leadz:1 ends here */
|
||||||
|
@ -134,12 +134,12 @@ let popcnt i = (popcnt [@inlined] ) i |> Int32.to_int
|
|||||||
|
|
||||||
#+begin_src c :tangle (eval c) :exports none
|
#+begin_src c :tangle (eval c) :exports none
|
||||||
CAMLprim int32_t trailz(int64_t i) {
|
CAMLprim int32_t trailz(int64_t i) {
|
||||||
return __builtin_ctzll (i);
|
return i == 0L ? 64 : __builtin_ctzll (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CAMLprim value trailz_bytecode(value i) {
|
CAMLprim value trailz_bytecode(value i) {
|
||||||
return caml_copy_int32(__builtin_ctzll (Int64_val(i)));
|
return caml_copy_int32(i == 0L ? 64 : __builtin_ctzll (Int64_val(i)));
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -158,12 +158,12 @@ let trailz i = trailz i |> Int32.to_int
|
|||||||
|
|
||||||
#+begin_src c :tangle (eval c) :exports none
|
#+begin_src c :tangle (eval c) :exports none
|
||||||
CAMLprim int32_t leadz(int64_t i) {
|
CAMLprim int32_t leadz(int64_t i) {
|
||||||
return __builtin_clzll(i);
|
return i == 0L ? 64 : __builtin_clzll(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CAMLprim value leadz_bytecode(value i) {
|
CAMLprim value leadz_bytecode(value i) {
|
||||||
return caml_copy_int32(__builtin_clzll (Int64_val(i)));
|
return caml_copy_int32(i == 0L ? 64 : __builtin_clzll (Int64_val(i)));
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
516
docs/common.html
516
docs/common.html
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
|||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||||
<head>
|
<head>
|
||||||
<!-- 2022-12-13 Tue 10:55 -->
|
<!-- 2023-04-20 Thu 10:54 -->
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>Top-level</title>
|
<title>Top-level</title>
|
||||||
@ -250,18 +250,18 @@ org_html_manager.setup(); // activate after the parameters are set
|
|||||||
<h2>Table of Contents</h2>
|
<h2>Table of Contents</h2>
|
||||||
<div id="text-table-of-contents">
|
<div id="text-table-of-contents">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#org4f42024">1. Summary</a></li>
|
<li><a href="#orgd03da44">1. Summary</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="outline-container-org4f42024" class="outline-2">
|
<div id="outline-container-orgd03da44" class="outline-2">
|
||||||
<h2 id="org4f42024"><span class="section-number-2">1</span> Summary</h2>
|
<h2 id="orgd03da44"><span class="section-number-2">1</span> Summary</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="postamble" class="status">
|
<div id="postamble" class="status">
|
||||||
<p class="author">Author: Anthony Scemama</p>
|
<p class="author">Author: Anthony Scemama</p>
|
||||||
<p class="date">Created: 2022-12-13 Tue 10:55</p>
|
<p class="date">Created: 2023-04-20 Thu 10:54</p>
|
||||||
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user