www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - dlib - d utility library

reply Timur Gafarov <gecko0307 gmail.com> writes:
dlib is a growing collection of native D language libraries serving as a 
framework for various higher-level projects - such as game engines, 
rendering pipelines and multimedia applications. It is written in D2 and 
has no external external dependencies aside D's standart library, Phobos.

Currently dlib contains the following packages:

dlib.core - standard algorithms, data structures, useful templates, etc.

dlib.functional - some functional programming idioms (HOFs, combiners, 
quantifiers, etc.)

dlib.math - linear algebra (vectors, matrices, quaternions, etc.)

dlib.geometry - computational geometry (ray casting, primitives, etc.)

dlib.image - image processing (filters, color correction, graphics 
formats I/O, support for 8 and 16-bit RGBA buffers and floating point 
operations).

http://code.google.com/p/dlib/
Sep 28 2012
next sibling parent "Craig Dillabaugh" <cdillaba cg.scs.carleton.ca> writes:
On Friday, 28 September 2012 at 09:43:34 UTC, Timur Gafarov wrote:
 dlib is a growing collection of native D language libraries 
 serving as a framework for various higher-level projects - such 
 as game engines, rendering pipelines and multimedia 
 applications. It is written in D2 and has no external external 
 dependencies aside D's standart library, Phobos.

 Currently dlib contains the following packages:

 dlib.core - standard algorithms, data structures, useful 
 templates, etc.

 dlib.functional - some functional programming idioms (HOFs, 
 combiners, quantifiers, etc.)

 dlib.math - linear algebra (vectors, matrices, quaternions, 
 etc.)

 dlib.geometry - computational geometry (ray casting, 
 primitives, etc.)

 dlib.image - image processing (filters, color correction, 
 graphics formats I/O, support for 8 and 16-bit RGBA buffers and 
 floating point operations).

 http://code.google.com/p/dlib/

Apart from a description of the project this site seems empty! Is there anywhere a person can download the source code/try this out. Thanks. Craig
Sep 28 2012
prev sibling next sibling parent "Danny Arends" <Danny.Arends gmail.com> writes:
 Apart from a description of the project this site seems empty! 
 Is
 there anywhere a person can download the source code/try this 
 out.

If you want to browse it online (without check-out): http://code.google.com/p/dlib/source/browse/ Gr, Danny
Sep 28 2012
prev sibling next sibling parent "Craig Dillabaugh" <cdillaba cg.scs.carleton.ca> writes:
On Friday, 28 September 2012 at 13:29:05 UTC, Danny Arends wrote:
 Apart from a description of the project this site seems empty! 
 Is
 there anywhere a person can download the source code/try this 
 out.

If you want to browse it online (without check-out): http://code.google.com/p/dlib/source/browse/ Gr, Danny

Thanks. Now I was able to find it. Craig
Sep 28 2012
prev sibling next sibling parent reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Friday, 28 September 2012 at 09:43:34 UTC, Timur Gafarov wrote:
 dlib is a growing collection of native D language libraries 
 serving as a framework for various higher-level projects - such 
 as game engines, rendering pipelines and multimedia 
 applications. It is written in D2 and has no external external 
 dependencies aside D's standart library, Phobos.

A note on your Vector implementation. Currently you use the vector operators, e.g. Vector!(T,size) opAddAssign (Vector!(T,size) v) body { arrayof[] += v.arrayof[]; return this; } This is fine for large vectors, but (correct me if I'm wrong), your vector class appears to be designed for small vectors. Those vector ops currently call a asm optimised function that uses SIMD instructions in a loop - it works well for larger vectors with hundreds of elements, but for small vectors it's significantly faster to just use: foreach (i; 0..size) arrayof[i] += v.arrayof[i]; I've also noticed that you've provided Matrix2x2 and Matrix4x4 as separate structs from the more generic Matrix. I'm guessing this is for specialisation. A more idiomatic way to handle this would be to use template specialisation to provide the optimised versions. That way, when people use Matrix!(T, 2, 2) they get all the benefits of Matrix2x2!T as well.
Sep 28 2012
next sibling parent Timur Gafarov <gecko0307 gmail.com> writes:
28.09.2012 20:47, Peter Alexander пишет:
 On Friday, 28 September 2012 at 09:43:34 UTC, Timur Gafarov wrote:
 dlib is a growing collection of native D language libraries serving as
 a framework for various higher-level projects - such as game engines,
 rendering pipelines and multimedia applications. It is written in D2
 and has no external external dependencies aside D's standart library,
 Phobos.

A note on your Vector implementation. Currently you use the vector operators, e.g. Vector!(T,size) opAddAssign (Vector!(T,size) v) body { arrayof[] += v.arrayof[]; return this; } This is fine for large vectors, but (correct me if I'm wrong), your vector class appears to be designed for small vectors. Those vector ops currently call a asm optimised function that uses SIMD instructions in a loop - it works well for larger vectors with hundreds of elements, but for small vectors it's significantly faster to just use: foreach (i; 0..size) arrayof[i] += v.arrayof[i]; I've also noticed that you've provided Matrix2x2 and Matrix4x4 as separate structs from the more generic Matrix. I'm guessing this is for specialisation. A more idiomatic way to handle this would be to use template specialisation to provide the optimised versions. That way, when people use Matrix!(T, 2, 2) they get all the benefits of Matrix2x2!T as well.

Thanks! I didn't realize that about vectors. I'm interested in performance optimization, so I will fix that as soon as possible. As for matrices - I used Matrix4x4 for a long time (that was just the simplest way), and recently introduced that generalized version. Eventually I will port everything into it.
Sep 29 2012
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-09-28 19:47, Peter Alexander wrote:

 A note on your Vector implementation. Currently you use the vector
 operators, e.g.

      Vector!(T,size) opAddAssign (Vector!(T,size) v)
      body
      {
          arrayof[] += v.arrayof[];
          return this;
      }

 This is fine for large vectors, but (correct me if I'm wrong), your
 vector class appears to be designed for small vectors. Those vector ops
 currently call a asm optimised function that uses SIMD instructions in a
 loop - it works well for larger vectors with hundreds of elements, but
 for small vectors it's significantly faster to just use:

 foreach (i; 0..size)
      arrayof[i] += v.arrayof[i];

Isn't the whole point of the array operators that it gives the compiler more semantic understanding of the code. Just as a foreach-loop does compared to a for-loop. So the compiler should be able to optimize this and generated the most optimal code. But the compiler might not be that good. -- /Jacob Carlborg
Sep 29 2012
prev sibling parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 28-Sep-12 21:47, Peter Alexander wrote:
 On Friday, 28 September 2012 at 09:43:34 UTC, Timur Gafarov wrote:
 dlib is a growing collection of native D language libraries serving as
 a framework for various higher-level projects - such as game engines,
 rendering pipelines and multimedia applications. It is written in D2
 and has no external external dependencies aside D's standart library,
 Phobos.

A note on your Vector implementation. Currently you use the vector operators, e.g. Vector!(T,size) opAddAssign (Vector!(T,size) v) body { arrayof[] += v.arrayof[]; return this; } This is fine for large vectors, but (correct me if I'm wrong), your vector class appears to be designed for small vectors. Those vector ops currently call a asm optimised function that uses SIMD instructions in a loop - it works well for larger vectors with hundreds of elements, but for small vectors it's significantly faster to just use: foreach (i; 0..size) arrayof[i] += v.arrayof[i];

(if size is fixed and is small e.g. < 10). foreach (i; TypeTuple!(1, 2, 3, 4 ... )) //too bad we still don't have static Iota in Phobos { arrayof[i] += v.arrayof[i]; } -- Dmitry Olshansky
Sep 29 2012
parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 29-Sep-12 20:39, Dmitry Olshansky wrote:
 On 28-Sep-12 21:47, Peter Alexander wrote:
 On Friday, 28 September 2012 at 09:43:34 UTC, Timur Gafarov wrote:
 dlib is a growing collection of native D language libraries serving as
 a framework for various higher-level projects - such as game engines,
 rendering pipelines and multimedia applications. It is written in D2
 and has no external external dependencies aside D's standart library,
 Phobos.

A note on your Vector implementation. Currently you use the vector operators, e.g. Vector!(T,size) opAddAssign (Vector!(T,size) v) body { arrayof[] += v.arrayof[]; return this; } This is fine for large vectors, but (correct me if I'm wrong), your vector class appears to be designed for small vectors. Those vector ops currently call a asm optimised function that uses SIMD instructions in a loop - it works well for larger vectors with hundreds of elements, but for small vectors it's significantly faster to just use: foreach (i; 0..size) arrayof[i] += v.arrayof[i];

(if size is fixed and is small e.g. < 10). foreach (i; TypeTuple!(1, 2, 3, 4 ... ))

 //too bad we still don't have static Iota in Phobos
 {
      arrayof[i] += v.arrayof[i];
 }

-- Dmitry Olshansky
Sep 29 2012
prev sibling parent Rory McGuire <rjmcguire gmail.com> writes:
--14dae93b5c5863e73204cad6db29
Content-Type: text/plain; charset=UTF-8

On Sep 29, 2012 2:55 PM, "Jacob Carlborg" <doob me.com> wrote:
 On 2012-09-28 19:47, Peter Alexander wrote:

 A note on your Vector implementation. Currently you use the vector
 operators, e.g.

      Vector!(T,size) opAddAssign (Vector!(T,size) v)
      body
      {
          arrayof[] += v.arrayof[];
          return this;
      }

 This is fine for large vectors, but (correct me if I'm wrong), your
 vector class appears to be designed for small vectors. Those vector ops
 currently call a asm optimised function that uses SIMD instructions in a
 loop - it works well for larger vectors with hundreds of elements, but
 for small vectors it's significantly faster to just use:

 foreach (i; 0..size)
      arrayof[i] += v.arrayof[i];

Isn't the whole point of the array operators that it gives the compiler

compared to a for-loop. So the compiler should be able to optimize this and generated the most optimal code. But the compiler might not be that good.
 --
 /Jacob Carlborg

--14dae93b5c5863e73204cad6db29 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <p><br> On Sep 29, 2012 2:55 PM, &quot;Jacob Carlborg&quot; &lt;<a href=3D"mailto:d= oob me.com">doob me.com</a>&gt; wrote:<br> &gt;<br> &gt; On 2012-09-28 19:47, Peter Alexander wrote:<br> &gt;<br> &gt;&gt; A note on your Vector implementation. Currently you use the vector= <br> &gt;&gt; operators, e.g.<br> &gt;&gt;<br> &gt;&gt; =C2=A0 =C2=A0 =C2=A0Vector!(T,size) opAddAssign (Vector!(T,size) v= )<br> &gt;&gt; =C2=A0 =C2=A0 =C2=A0body<br> &gt;&gt; =C2=A0 =C2=A0 =C2=A0{<br> &gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0arrayof[] +=3D v.arrayof[];<br> &gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return this;<br> &gt;&gt; =C2=A0 =C2=A0 =C2=A0}<br> &gt;&gt;<br> &gt;&gt; This is fine for large vectors, but (correct me if I&#39;m wrong),= your<br> &gt;&gt; vector class appears to be designed for small vectors. Those vecto= r ops<br> &gt;&gt; currently call a asm optimised function that uses SIMD instruction= s in a<br> &gt;&gt; loop - it works well for larger vectors with hundreds of elements,= but<br> &gt;&gt; for small vectors it&#39;s significantly faster to just use:<br> &gt;&gt;<br> &gt;&gt; foreach (i; 0..size)<br> &gt;&gt; =C2=A0 =C2=A0 =C2=A0arrayof[i] +=3D v.arrayof[i];<br> &gt;<br> &gt;<br> &gt; Isn&#39;t the whole point of the array operators that it gives the com= piler more semantic understanding of the code. Just as a foreach-loop does = compared to a for-loop. So the compiler should be able to optimize this and= generated the most optimal code. But the compiler might not be that good.<= br> &gt;<br> &gt; -- <br> &gt; /Jacob Carlborg<br> +1<br> </p> --14dae93b5c5863e73204cad6db29--
Sep 29 2012