Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. 2D rectanlge array type (Nathan H?sken)
2. Re: 2D rectanlge array type (Nick Vanderweit)
3. Re: 2D rectanlge array type (Bob Ippolito)
4. Re: 2D rectanlge array type (Nathan H?sken)
5. Strange Failure in extern code via FFI (Nathan H?sken)
6. Re: Strange Failure in extern code via FFI - SOLVED
(Nathan H?sken)
----------------------------------------------------------------------
Message: 1
Date: Thu, 12 Sep 2013 18:28:07 +0200
From: Nathan H?sken <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] 2D rectanlge array type
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Hey,
I am experimenting with machine learning in haskell. For training a
model, I need to input a list of features. A features itself is a set of
floating point numbers. So my training data has the type:
[Feature]
What I am wondering is which type I should use for Feature. As I said,
it is a set of floats. But every feature must have exactly the same
number of floats. I could use
type Feature = [Float]
but that would not ensure that every feature has the same number of
flaots. I could use tuples
type Feature = (Float,Float,Float,Float,Float ...)
The number of features varies from application to application. And I do
not know how to encode that with tuples. Also the number of features can
get very big (in extreme cases up to ~1000, in normal cases ~100).
How would you do that?
Thanks!
Nathan
------------------------------
Message: 2
Date: Thu, 12 Sep 2013 13:09:11 -0600
From: Nick Vanderweit <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] 2D rectanlge array type
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Nathan,
It is actually possible (and pretty easy) to encode natural numbers as
types [1]. You could create a sequence type which is parameterized
over both the element type and the number of contained elements.
Nick
[1] http://www.haskell.org/haskellwiki/Type_arithmetic
On 09/12/2013 10:28 AM, Nathan H?sken wrote:
> Hey,
>
> I am experimenting with machine learning in haskell. For training
> a model, I need to input a list of features. A features itself is a
> set of floating point numbers. So my training data has the type:
>
> [Feature]
>
> What I am wondering is which type I should use for Feature. As I
> said, it is a set of floats. But every feature must have exactly
> the same number of floats. I could use
>
> type Feature = [Float]
>
> but that would not ensure that every feature has the same number
> of flaots. I could use tuples
>
> type Feature = (Float,Float,Float,Float,Float ...)
>
> The number of features varies from application to application. And
> I do not know how to encode that with tuples. Also the number of
> features can get very big (in extreme cases up to ~1000, in normal
> cases ~100).
>
> How would you do that?
>
> Thanks! Nathan
>
>
> _______________________________________________ Beginners mailing
> list [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iF4EAREIAAYFAlIyEVMACgkQJlmDAU/j7BAI1AEAqLQLSyMYwJfzWK5LoNlv5OFK
EYI5cxR8sZU3upZQYoQA/3Tk8iNW3a68RiDxF1nSfgo/ENhjfqTbxhFSo5M46y49
=wUuu
-----END PGP SIGNATURE-----
------------------------------
Message: 3
Date: Thu, 12 Sep 2013 15:13:28 -0400
From: Bob Ippolito <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] 2D rectanlge array type
Message-ID:
<cacwmpm8hk7drbz7cpxnrq90_oqa7drjl-gupvt0mkxyjl0d...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I would probably use repa for this sort of application.
http://hackage.haskell.org/package/repa
On Thursday, September 12, 2013, Nathan H?sken wrote:
> Hey,
>
> I am experimenting with machine learning in haskell. For training a model,
> I need to input a list of features. A features itself is a set of floating
> point numbers. So my training data has the type:
>
> [Feature]
>
> What I am wondering is which type I should use for Feature. As I said, it
> is a set of floats. But every feature must have exactly the same number of
> floats. I could use
>
> type Feature = [Float]
>
> but that would not ensure that every feature has the same number of
> flaots. I could use tuples
>
> type Feature = (Float,Float,Float,Float,Float ...)
>
> The number of features varies from application to application. And I do
> not know how to encode that with tuples. Also the number of features can
> get very big (in extreme cases up to ~1000, in normal cases ~100).
>
> How would you do that?
>
> Thanks!
> Nathan
>
>
> ______________________________**_________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130912/4cfc6097/attachment-0001.html>
------------------------------
Message: 4
Date: Fri, 13 Sep 2013 00:21:36 +0200
From: Nathan H?sken <[email protected]>
To: Nick Vanderweit <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] 2D rectanlge array type
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hey,
Thanks for the tips. But when the lists get really long, this methods
seems to be very cumbersome, or am I misssing something?
Regards,
Nathan
Am 9/12/2013 9:09 PM, schrieb Nick Vanderweit:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Hi Nathan,
>
> It is actually possible (and pretty easy) to encode natural numbers as
> types [1]. You could create a sequence type which is parameterized
> over both the element type and the number of contained elements.
>
>
> Nick
>
> [1] http://www.haskell.org/haskellwiki/Type_arithmetic
>
> On 09/12/2013 10:28 AM, Nathan H?sken wrote:
>> Hey,
>>
>> I am experimenting with machine learning in haskell. For training
>> a model, I need to input a list of features. A features itself is a
>> set of floating point numbers. So my training data has the type:
>>
>> [Feature]
>>
>> What I am wondering is which type I should use for Feature. As I
>> said, it is a set of floats. But every feature must have exactly
>> the same number of floats. I could use
>>
>> type Feature = [Float]
>>
>> but that would not ensure that every feature has the same number
>> of flaots. I could use tuples
>>
>> type Feature = (Float,Float,Float,Float,Float ...)
>>
>> The number of features varies from application to application. And
>> I do not know how to encode that with tuples. Also the number of
>> features can get very big (in extreme cases up to ~1000, in normal
>> cases ~100).
>>
>> How would you do that?
>>
>> Thanks! Nathan
>>
>>
>> _______________________________________________ Beginners mailing
>> list [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iF4EAREIAAYFAlIyEVMACgkQJlmDAU/j7BAI1AEAqLQLSyMYwJfzWK5LoNlv5OFK
> EYI5cxR8sZU3upZQYoQA/3Tk8iNW3a68RiDxF1nSfgo/ENhjfqTbxhFSo5M46y49
> =wUuu
> -----END PGP SIGNATURE-----
------------------------------
Message: 5
Date: Fri, 13 Sep 2013 13:05:36 +0200
From: Nathan H?sken <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Strange Failure in extern code via FFI
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hey,
I have C++ code which works perfectly when compiled in C++ program. Now
I want to call this C++ code from haskell via FFI. When doing so, I get
this error in a HUnit test program:
test-rf: malloc.c:2369: sysmalloc: Assertion `(old_top == (((mbinptr)
(((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct
malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >=
(unsigned long)((((__builtin_offsetof (struct malloc_chunk,
fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) -
1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask)
== 0)' failed.
Something wrong with memory allocation I guess. The code I am running is
complex and not mine. But I ran gdb over the problem and the error
occurs at this code:
data = alloc_.allocate(capacity);
gdb tells me, that capacity==2, so it does not seem to be an out of
memory error. Also about alloc_, gdb tells me:
(gdb) p alloc_
$3 = {<__gnu_cxx::new_allocator<unsigned int>> = {<No data fields>}, <No
data fields>}
The stack frames above the shown code are:
#0 0x00007ffff69a8037 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff69ab698 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff69efb7a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff69f306c in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff69f4580 in malloc () from /lib/x86_64-linux-gnu/libc.so.6
#5 0x00007ffff7b3666d in operator new(unsigned long) () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x000000000040dbd0 in allocate (__n=2, this=0x7fffffff9a48) at
/usr/include/c++/4.7/ext/new_allocator.h:94
So ... it seems to be something with the new_allocator ...
Maybe I am doing something different than in the C++ code, but I do not
know what so I am suspecting it has something to do with the haskell FFI.
Any Ideas?
Thanks!
Nathan
------------------------------
Message: 6
Date: Fri, 13 Sep 2013 13:14:22 +0200
From: Nathan H?sken <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Strange Failure in extern code via
FFI - SOLVED
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Never mind.
I did something wrong at some other C++ code I called via the FFI. There
I did something that corrupted the memory.
I found out using valgrind.
So, not haskell related and solved. Sorry for the bother.
Regards,
Nathan
On 09/13/2013 01:05 PM, Nathan H?sken wrote:
> Hey,
>
> I have C++ code which works perfectly when compiled in C++ program. Now
> I want to call this C++ code from haskell via FFI. When doing so, I get
> this error in a HUnit test program:
>
> test-rf: malloc.c:2369: sysmalloc: Assertion `(old_top == (((mbinptr)
> (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct
> malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >=
> (unsigned long)((((__builtin_offsetof (struct malloc_chunk,
> fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) -
> 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask)
> == 0)' failed.
>
> Something wrong with memory allocation I guess. The code I am running is
> complex and not mine. But I ran gdb over the problem and the error
> occurs at this code:
>
> data = alloc_.allocate(capacity);
>
> gdb tells me, that capacity==2, so it does not seem to be an out of
> memory error. Also about alloc_, gdb tells me:
>
> (gdb) p alloc_
> $3 = {<__gnu_cxx::new_allocator<unsigned int>> = {<No data fields>}, <No
> data fields>}
>
> The stack frames above the shown code are:
>
> #0 0x00007ffff69a8037 in raise () from /lib/x86_64-linux-gnu/libc.so.6
> #1 0x00007ffff69ab698 in abort () from /lib/x86_64-linux-gnu/libc.so.6
> #2 0x00007ffff69efb7a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
> #3 0x00007ffff69f306c in ?? () from /lib/x86_64-linux-gnu/libc.so.6
> #4 0x00007ffff69f4580 in malloc () from /lib/x86_64-linux-gnu/libc.so.6
> #5 0x00007ffff7b3666d in operator new(unsigned long) () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #6 0x000000000040dbd0 in allocate (__n=2, this=0x7fffffff9a48) at
> /usr/include/c++/4.7/ext/new_allocator.h:94
>
> So ... it seems to be something with the new_allocator ...
> Maybe I am doing something different than in the C++ code, but I do not
> know what so I am suspecting it has something to do with the haskell FFI.
>
> Any Ideas?
> Thanks!
> Nathan
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 63, Issue 17
*****************************************