Search Results

Search found 11 results on 1 pages for 'ublas'.

Page 1/1 | 1 

  • ublas::bounded_vector<> being resized?

    - by n2liquid
    Now, seriously... I'll refrain from using bad words here because we're talking about the Boost fellows. It MUST be my mistake to see things this way, but I can't understand why, so I'll ask it here; maybe someone can enlighten me in this matter. Here it goes: uBLAS has this nice class template called bounded_vector<> that's used to create fixed-size vectors (or so I thought). From the Effective uBLAS wiki (http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBLAS): The default uBLAS vector and matrix types are of variable size. Many linear algebra problems involve vectors with fixed size. 2 and 3 elements are common in geometry! Fixed size storage (akin to C arrays) can be implemented efficiently as it does not involve the overheads (heap management) associated with dynamic storage. uBLAS implements fixed sizes by changing the underling storage of a vector/matrix to a "bounded_array" from the default "unbounded_array". Alright, this bounded_vector<> thing is used to free you from specifying the underlying storage of the vector to a bounded_array<> of the specified size. Here I ask you: doesn't it look like this bounded vector thing has fixed size to you? Well, it doesn't have. At first I felt betrayed by the wiki, but then I reconsidered the meaning of "bounded" and I think I can let it pass. But in case you, like me (I'm still uncertain), is still wondering if this makes sense, what I found out is that the bounded_vector<> actually can be resized, it may only not be greater than the size specified as template parameter. So, first off, do you think they've had a good reason not to make a real fixed<< size vector or matrix type? Do you think it's okay to "sell" this bounded -- as opposed to fixed-size -- vector to the users of my library as a "fixed-size" vector replacement, even named "Vector3" or "Vector2", like the Effective uBLAS wiki did? Do you think I should somehow implement a vector with fixed size for this purpose? If so, how? (Sorry, but I'm really new to uBLAS; just tried it today) I am developing a 3D game. Should uBLAS be used for the calculations involved in this ("hey, geometry!", per Effective uBLAS wiki)? What replacement would you suggest, if not? -- edit And just in case, yes, I've read this warning: It should be noted that this only changes the storage uBLAS uses for the vector3. uBLAS will still use all the same algorithm (which assume a variable size) to manipulate the vector3. In practice this seems to have no negative impact on speed. The above runs just as quickly as a hand crafted vector3 which does not use uBLAS. The only negative impact is that the vector3 always store a "size" member which in this case is redundant [or isn't it? I mean......]. I see it uses the same algorithm, assuming a variable size, but if an operation were to actually change its size, shouldn't it be stopped (assertion)? ublas::bounded_vector<float,3> v3; ublas::bounded_vector<float,2> v2; v3 = v2; std::cout << v3.size() << '\n'; // prints 2 Oh, come on, isn't this just plain betrayal?

    Read the article

  • Passing Boost uBLAS matrices to OpenGL shader

    - by AJM
    I'm writing an OpenGL program where I compute my own matrices and pass them to shaders. I want to use Boost's uBLAS library for the matrices, but I have little idea how to get a uBLAS matrix into OpenGL's shader uniform functions. matrix<GLfloat, column_major> projection(4, 4); // Fill matrix ... GLuint projectionU = glGetUniformLocation(shaderProgram, "projection"); glUniformMatrix4fv(projectionU, 1, 0, (GLfloat *)... Um ...); Trying to cast the matrix to a GLfloat pointer causes an invalid cast error on compile.

    Read the article

  • boost ublas: rotate 2d vector

    - by AndreasT
    Erm. I hope I am seriously overlooking something. I want to rotate a 2d vector (kartesian) v by a certain angle phi. I can't find a function that generates the appropriate matrix or just performs that function. I know how to do this by hand. I am looking for a ublas utility "something" that does this for me.

    Read the article

  • C++ boost ublas + units dimension constraints

    - by aaa
    hello. I am seeking advice on design/general idea on how to force matrix dimension constraints on ublas matrix/vector possibly using boost units. For example, let matrix A have dimensions of time x force (for example) // does not have dimensions, time x force and force x time are not distinguished. matrix<double> A; //something like? dimension<time, force, matrix<double> > A; dimension<force, time, matrix<double> > B = trans(A); have you done something like this or do you have some good idea about how to organize such constraints? Thank you

    Read the article

  • C++, name collision across different namespace

    - by aaa
    hello. I am baffled by the following name collision: namespace mp2 { boost::numeric::ublas::matrix_range<M> slice(M& m, const R1& r1, const R2& r2) { namespace ublas = boost::numeric::ublas; ublas::range r1_(r1.begin(), r1.end()), r2_(r2.begin(), r2.end()); return ublas::matrix_range<M>(m, r1_, r2_); } double energy(const Wavefunction &wf) { const Wavefunction::matrix& C = wf.coefficients(); int No = wf.occupied().size(); foreach (const Basis::MappedShell& P, basis.shells()) { slice(C, range(No), range(P)); the error from g++4.4 is 7 In file included from mp2.cpp:1: 8 /usr/include/boost/numeric/ublas/fwd.hpp: In function âdouble mp2::energy(const Wavefunction&)â: 9 /usr/include/boost/numeric/ublas/fwd.hpp:32: error: âboost::numeric::ublas::sliceâ is not a function, 10 ../../src/mp2/energy.hpp:98: error: conflict with âtemplate<class M, class R1, class R2> boost::numeric::ublas::matrix_range<M> mp2::slice(M&, const R1&, const R2&)â 11 ../../src/mp2/energy.hpp:123: error: in call to âsliceâ 12 /usr/include/boost/numeric/ublas/fwd.hpp:32: error: âboost::numeric::ublas::sliceâ is not a function, 13 ../../src/mp2/energy.hpp:98: error: conflict with âtemplate<class M, class R1, class R2> boost::numeric::ublas::matrix_range<M> mp2::slice(M&, const R1&, const R2&)â 14 ../../src/mp2/energy.hpp:129: error: in call to âsliceâ 15 make: *** [mp2.lo] Error 1 ublas segment is namespace boost { namespace numeric { namespace ublas { typedef basic_slice<> slice; why is slice in ublas collides with slice in mp2? I and fairly certain there is no using namespace ublas in the code and in includes. thank you

    Read the article

  • wrapping boost::ublas with swig

    - by leon
    I am trying to pass data around the numpy and boost::ublas layers. I have written an ultra thin wrapper because swig cannot parse ublas' header correctly. The code is shown below #include <boost/numeric/ublas/vector.hpp> #include <boost/numeric/ublas/matrix.hpp> #include <boost/lexical_cast.hpp> #include <algorithm> #include <sstream> #include <string> using std::copy; using namespace boost; typedef boost::numeric::ublas::matrix<double> dm; typedef boost::numeric::ublas::vector<double> dv; class dvector : public dv{ public: dvector(const int rhs):dv(rhs){;}; dvector(); dvector(const int size, double* ptr):dv(size){ copy(ptr, ptr+sizeof(double)*size, &(dv::data()[0])); } ~dvector(){} }; with the SWIG interface that looks something like %apply(int DIM1, double* INPLACE_ARRAY1) {(const int size, double* ptr)} class dvector{ public: dvector(const int rhs); dvector(); dvector(const int size, double* ptr); %newobject toString; char* toString(); ~dvector(); }; I have compiled them successfully via gcc 4.3 and vc++9.0. However when I simply run a = dvector(array([1.,2.,3.])) it gives me a segfault. This is the first time I use swigh with numpy and not have fully understanding between the data conversion and memory buffer passing. Does anyone see something obvious I have missed? I have tried to trace through with a debugger but it crashed within the assmeblys of python.exe. I have no clue if this is a swig problem or of my simple wrapper. Anything is appreciated.

    Read the article

  • Providing *implicit* conversion operator for template specialization

    - by Neil G
    I have a templated sparse_vector<T> class, and I am also using Boost UBLAS. How would I provide implicit conversions between sparse_vector<double> and boost::numeric::ublas::compressed_vector<double>? I would also like to provide similar conversions between std::vector<double> and boost::numeric::ublas::vector<double>. (I am using gcc 4.4 with C++0x enabled.)

    Read the article

  • VC7.1 C1204 internal compiler error

    - by Nathan Ernst
    I'm working on modifying Firaxis' Civilization 4 core game DLL. The host application is built using VC7, hence the constraint (source not provided for the host EXE). I've been working on rewriting a large chunk of the code (focusing on low-hanging performance issues & memory leaks). I recently ran into an internal compiler error when trying to mod the code to use an array class instead of dynamically allocated 2-d arrays, I was going to use matrices from the boost lib (Civ4 is already using boost, so why not?). Basically, the issue comes down to: if I include "boost/numeric/ublas/matrix.hpp", I run into an internal compiler error C1204. MSDN has this to say: MSDN C1204 KB has this to say: KB 883655 So, I'm curious, is it possible to solve this error without a KB/SP being applied and dramatically reducing the complexity of the code? Additionally, as VC7 is no longer "supported", does anyone have a valid (supported) link for a VC7 service pack?

    Read the article

  • how to implement a sparse_vector class

    - by Neil G
    I am implementing a templated sparse_vector class. It's like a vector, but it only stores elements that are different from their default constructed value. So, sparse_vector would store the index-value pairs for all indices whose value is not T(). I am basing my implementation on existing sparse vectors in numeric libraries-- though mine will handle non-numeric types T as well. I looked at boost::numeric::ublas::coordinate_vector and eigen::SparseVector. Both store: size_t* indices_; // a dynamic array T* values_; // a dynamic array int size_; int capacity_; Why don't they simply use vector<pair<size_t, T>> data_; My main question is what are the pros and cons of both systems, and which is ultimately better? The vector of pairs manages size_ and capacity_ for you, and simplifies the accompanying iterator classes; it also has one memory block instead of two, so it incurs half the reallocations, and might have better locality of reference. The other solution might search more quickly since the cache lines fill up with only index data during a search. There might also be some alignment advantages if T is an 8-byte type? It seems to me that vector of pairs is the better solution, yet both containers chose the other solution. Why?

    Read the article

1