Large boost::multi_array Problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Large boost::multi_array Problem

Adam Hartshorne
Hi,

I have the following problem, I make a boost::multi_array<float,2> of
size X by X. I initialise this using the following line

typedef boost::multi_array<float, 2> array_type;
array_type D(boost::extents[num_vertices][num_vertices]);

This works fine up to a size of 5000 x 5000 then my program crashes at
the definition stage due to memory requirements. I am assuming the
boost::extents call stops my program creating a multi array of a size
bigger than 5000 x 5000. However in certain situations I need a bigger
2D array, any thoughts on how I can achieve this?

Adam

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

A third constructor for boost::thread

Hector C.
I think boost::thread will beneficiate from a third constructor:

thread::thread( boost::shared_ptr< boost::function0<void>& > )

1. This constructor will allow to use functors that are heavy to copy or simply non - copiable.

2. This contructor will also allow polymorphic functors. For example, in the following code, the copying of the functor destroys its polymorphism (there is not any 2 printed in the output) :

#include <boost/thread/thread.hpp>
#include <iostream>

class A
{
public:
    unsigned int m_a;

    A( unsigned int a_a ) : m_a( a_a ) {}

    void Begin() {boost::thread ( * this );}

    void operator ()()
    {foo(); std::cout << m_a;}

    virtual void foo() {m_a = 3; std::cout << m_a;}
};

class B : public A
{
public:
    B( unsigned int a_a ) : A( a_a ) {}

    void foo() {m_a = 2; std::cout << m_a;}
};

int main()
{
    B b( 7 );
    b.Begin();

    std::cout << b.m_a;
    system("pause");
     return 0;
}


++Hector C.


----------------------------------


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: A third constructor for boost::thread

Peter Dimov
Calderon Hector wrote:

> I think boost::thread will beneficiate from a third constructor:
>
> thread::thread( boost::shared_ptr< boost::function0<void>& > )
>
> 1. This constructor will allow to use functors that are heavy to
> copy or simply non - copiable.
>
> 2. This contructor will also allow polymorphic functors. For
> example, in the following code, the copying of the functor destroys
> its polymorphism (there is not any 2 printed in the output) :
>
> #include <boost/thread/thread.hpp>
> #include <iostream>
>
> class A
> {
> public:
>    unsigned int m_a;
>
>    A( unsigned int a_a ) : m_a( a_a ) {}
>
>    void Begin() {boost::thread ( * this );}
>
>    void operator ()()
>    {foo(); std::cout << m_a;}
>
>    virtual void foo() {m_a = 3; std::cout << m_a;}
> };

Drop operator() and use boost::bind( &A::foo, shared_ptr<A>( new B ) ) as a
thread proc.

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Please do not start new threads by replying (was: A third constructor for boost::thread)

David Abrahams
In reply to this post by Hector C.
Calderon Hector <[hidden email]> writes:

> I think boost::thread will beneficiate from a third constructor:

See http://www.boost.org/more/discussion_policy.htm#effective

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: A third constructor for boost::thread

Hector C.
In reply to this post by Peter Dimov

>Drop operator() and use boost::bind( &A::foo, shared_ptr( new B ) ) as a
>
thread proc.

Thank you, it worked perfectly.

++Hector C.


----------------------------------


Blab-away for as little as 1ยข/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users