C/C++ :: How To Assign Pointers For Boost Matrix

Aug 4, 2014

I am using boost matrix for generating matrices used for filters. I wan to assign a pointer to these matrices so i can call them out of the function. but i am not able to understand where i am failing. the example code is here.

int main(int argc, char *argv[]) {
QApplication a(argc, argv);
identity_matrix<double> M(3);
std::cout<<M<<std::endl;

[Code] ....

View 9 Replies


ADVERTISEMENT

C/C++ :: Assign A Matrix To Submatrix Of A Bigger Matrix?

Feb 27, 2012

I want to assign a matrix to submatrix of a bigger matrix.

ublas::matrix<int> A(8,5);
ublas::matrix<int> B(2,5);
for(size_t i=0;i<A.size1();++i)
for(size_t j=0;j<A.size2();++j)
        A(i,j)=i*A.size2()+j+1;
for(size_t i=0;i<B.size1();++i)
    for(size_t j=0;j<B.size2();++j)
        B(i,j)=i*B.size2()+j+5;
ublas::matrix_range<ublas::matrix<int> > a(A,ublas::range(0,2),ublas::range(0,5));
a=B;  

and it works.

but if the matrix is compressed_matrix type, there's something with it. the error log as below:

Check failed in file boost_1_48_0/boost/numeric/ublas/detail/matrix_assign.hpp at line 1078:
detail::expression_type_check (m, cm)
terminate called after throwing an instance of 'boost::numeric::ublas::external_logic'
what(): external logic
Aborted

I'm not sure this is a bug or not.

View 2 Replies View Related

C++ :: Matrix Multiplication Using Pointers

Feb 15, 2014

Code:
#include<stdio.h>
#include<conio.h>
void main()

[Code] .....

This program on running returns an error of "ILLEGAL USE OF POINTER".

View 4 Replies View Related

C :: Matrix Multiplication Using Pointers

Feb 17, 2014

Code:
#include<stdio.h> Code: #include<conio.h>
void main() {
int *a[2][2],*b[2][2],*c[2][2],i,j,k;
Printf("
ENTER a MATRIX ELEMENTS

[Code] .....

View 4 Replies View Related

C/C++ :: Iterate 2D Matrix In Order To Exchange Columns And Rows Using Pointers

Jan 19, 2014

I am trying to iterate a matrix in order to exchange rows and columns element by element. Although the function that exchanges the rows has come out well, i don't seem to figure out how to do the same on columns.The columns switch for a matrix like

1 2 3
1 2 3
1 2 3

if i try to switch column 3 and 2,is:

1 3 2
1 3 2
1 2 3

Here are both of the functions:

void interchange_rows(int *p,int n,int r1,int r2){
    int temp;
    for(int i=0;i<n;i++){
            temp=*(p+r1*n+i);
            *(p+r1*n+i)=*(p+r2*n+i);
            *(p+r2*n+i)=temp;
   
[Code] ......

View 1 Replies View Related

C++ :: Using OOP To Implement Matrix Class That Provide Basic Matrix Operations

Mar 27, 2013

i want to know how i can solve this question? do i need to create a class or write the program codes.

View 12 Replies View Related

C++ :: Accept Matrix As Argument And Display Its Multiplication Matrix

Jun 1, 2014

I just want to know the code of the program: Write code to accept matrix as aurgument and display its multiplication matrix which return its multiplication matrix.

View 1 Replies View Related

C++ :: Find Matrix P For A Square Matrix A

May 25, 2014

I have to prepare a project. But I don t know how can I do this. Program will find a matrix P for a square matrix A such that P^-1 A P ....

View 15 Replies View Related

C :: Create Array Of Pointers To Pointers Which Will Point To Array Of Pointers

Feb 28, 2014

I'm trying to create an array of pointers to pointers which will point to array of pointers (to strings) I tried

Code:

int i;
char *string[]={
"my name is dave",
"we like to dance together",
"sunny day",
"hello",

[code]...

the app keeps crashing , I don't know how to make the array-elements to point to another array-elements..

View 4 Replies View Related

C++ :: Comparing Char Pointers To Integer Pointers

May 21, 2013

I am a little confused while comparing char pointers to integer pointers. Here is the problem:

Consider the following statement;
char *ptr = "Hello";
char cArr[] = "Hello";

When I do cout << ptr; it prints Hello, same is the case with the statement
cout << cArr;

As ptr and cArr are pointers, they should print addresses rather than contents, but if I have an interger array i.e.
int iArr[] = {1, 2, 3};

If I cout << iArr; it displays the expected result(i.e. prints address) but pointers to character array while outputting doesn't show the address but shows the contents, Why??

View 2 Replies View Related

C++ :: How To Boost Up Execution

Feb 23, 2013

I wrote a program to run long simulations, in one cpu core computation. During the run, I checked the cpu occupation was always around 85%.

Since my simulation took time to run. How can I boost it up to make my cpu run at 100%? Is that because my RAM is not fast enough?

info about my laptop: cpu frequency: up to 3.2 GHz. RAM frequency: 1333 MHz.

View 2 Replies View Related

C++ :: Passing A Reference Of Arg (boost Lib)

Dec 19, 2013

I have in my main(), a function that creates my arg object using boost/program_options.hpp i want to pass this object to another function using templates like this:

Code:
template <typename Targ>
void Count(Targ & arg){
MyObj<string> QueryTab(arg["input-file"].as<string>()); //line number is 352
...
}

However I get an error:

Code:
../include/Filter.hpp: In member function ‘void Count(Targ&)’:
../include/Filter.hpp:352:40: error: expected primary-expression before ‘>’ token
../include/Filter.hpp:352:42: error: expected primary-expression before ‘)’ token
... obviously it does not recognize my intention, what did I do wrong?

View 2 Replies View Related

C++ :: How To Get Boost Libraries To Work With QT IDE

Mar 5, 2013

I have an issue getting boost libraries to work with QT IDE. Here are relevant lines from my .pro file...

INCLUDEPATH += c:/users/bob/desktop/boost_1_53_0/
LIBS += -LC:c:/users/bob/desktop/boost_1_53_0/stage/lib64

After adding #include <boost/filesystem.hpp> I get error...

C:UsersobDesktopqtpuntitled5mainwindow.cpp:3: error: C1083: Cannot open include file: 'boost/filesystem.hpp': No such file or directory

The IDE does not highlight the line. The error only appears on compilation.

View 2 Replies View Related

C++ :: Boost Filesystem Exception

Mar 12, 2014

I have one problem deleting a file with boost. The file is opened in another application and cannot be deleted. I am supposed to received an exception error but I don't get it.

Here is my piece of code, very simple:

bool delete_file(const string &path) {
boost::filesystem::path bpath(path);
try {
if (boost::filesystem::remove(bath)) return true;

[Code] ....

I have put a breakpoint inside the catch part but it does not come to this point. Instead, the the output window of visual studio, I got these lines:

First-chance exception at 0x00007FFD2E575A88 in site_server.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x00000070F8E3E920.
Unhandled exception at at 0x00007FFD2E575A88 in site_server.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x00000070F8E3E920.

How to manage this situation?

View 1 Replies View Related

Visual C++ :: Boost Is Not A Namespace

Nov 29, 2013

exportmain.cpp

Code:
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
// Create an empty property tree object
using boost::property_tree::ptree;
#include "kwxport.h"
#include "resource.h"

[Code] ....

How can I make boost:roperty_tree:tree get recognized by the compiler?

View 2 Replies View Related

Visual C++ :: How To Add Boost Libraries

Oct 1, 2013

i have written an algorithm in VC++ 2010 express edition. i have used the following header files

#include<iostream>
#include<string>
#include<sstream>
#include<ctime>
#include<cassert>
#include<fstream>
#include<vector>

[Code]...

the algorithm worked fine in vc 2010 express edition....

the following header files are not working in vc5

#include<regex>
#include<tuple>
#include<numeric>
#include<unordered_set>
#include "clip.h"

Looks like some of hte boost libraries have to added with vc5.. If any one knows how to add boost libraries with vc5.

showing lot of errors in vc5... not able to run the algorithm in vc5. Our company has only vc5.... the algorithm has to be implemented in vc 2010....

View 2 Replies View Related

C++ :: How To Read Tag Name Of Boost Ptree

Mar 23, 2014

[URL] ....

I wonder how tag reading can be achieved? If say I have a file like

<name>
<firstname>John</firstname>
<surname>Robinson</surname>
</name>

I'd like to read "firstname" or "surname" instead of John or Robinson ....

View 4 Replies View Related

C++ :: Use Boost / Regex For Regular Expressions?

Sep 5, 2013

So I need to use boost/regex for regular expressions. someone told me that it needs to be built. the first problem is boost doesn't tell you how to build it and the second is i did sudo apt-get install libboost something. I don't remember the exact name of the package. it installed but i dont know how i would build it when its installed.

View 2 Replies View Related

C++ :: Error Handling When Using Boost NonCopyable

Aug 2, 2014

I have been using a Boost NonCopyable library in Microsoft Visual Studio 2013.

What I have is the following error message:

Error1error C2280: 'boost::noncopyable_::noncopyable::noncopyable(const boost::noncopyable_::noncopyable &)' : attempting to reference a deleted functionc:usersjohndocumentsvisual studio 2013projectsdonttreaddonttreaddonttread.cpp181DontTread

Now what I want to rectify the error is to throw an exception, so that the program can compile smoothly.

View 4 Replies View Related

C++ :: Static Linking Boost Library

Dec 17, 2014

I have written a program that uses boost in visual studio 2012. The only boost library I used is filesystem by doing.

1)Properties->Linker->General and adding the path or the .lib to the additional dependencies. The libraries, link at compile time.However when i move the exe to a different computer, it doesn't work. Therefore the libraries were dynamically not statically linked. So my question is how do I statically link the filesystem library, so that i can include boost/filesystem.hpp in visual studio 2012?

View 1 Replies View Related

C++ :: Boost Memory Mapped Object

Aug 21, 2014

i've created dll and implemented shared memory that every connected process can use. My problem is that i can't change anything in object, which is stored in the memory.

my class :

class MyClass
{
public:
MyClass();
void test();
int counter;
};
void MyClass::test() {
MessageBoxA(NULL, "test", "test", 0x0000000L);
counter++;
}

in stdafx.h i have :

static offset_ptr<MyClass> offset_mt;
static managed_shared_memory *memSegment;

I initialize shared memory and pointer :

memSegment = new managed_shared_memory(create_only, SHARED_MEMORY_NAME, 4096);
offset_mt = memSegment->construct<MyClass>("MyClass myClass")();

And then in an exported function i call

offset_mt.get()->test();

Im calling this from Java using JNA and result is a memory error (Invalid memory access). However, if I delete 'counter++' from test method, everything works fine - message box appears. Is there a limitation that I cant modify objects inside mapped memory or is this done the other way?

View 3 Replies View Related

C/C++ :: Linking Boost Thread With Xcode

Sep 30, 2014

I have built Boost from the website using

./bootstrap.sh
./b2 install

I think all are installed properly. I am trying to use Xcode to include the library of boost:thread.My code links to the header file properly with " #include "boost/thread.hpp"" commented, as seen from the following:

However, it could not link properly to boost-thread if "#include "boost/thread.hpp"" is un-commented.

Error page is shown as:

I have linked the dynamic library libboost_thread.a and libboost_thread.dylib and included /usr/local/include into header search path and /usr/local/lib into library search path.

View 1 Replies View Related

C++ :: Listing Files With Boost Filesystem

Jun 7, 2013

I have the following code which is based of the tut3.cpp example at: [URL] ....

However, I'm not entirely sure how to retrieve the full file path which I'd like to use to get the file size. So essentially the aim is to go through a directory and list all the file sizes.

Code:
if (exists(p)) {
if (is_directory(p)) {
cout << p << " is a directory containing:
";
copy(directory_iterator(p), directory_iterator(), // directory_iterator::value_type

[Code] ....

View 1 Replies View Related

C++ :: Mesh Array Of Double Boost

Jul 11, 2012

I wanna create mesh Array using boost elements, that will be do the same that code below, but can accept numbers of double. Any boost array that give me needed functionality. It will be great that advised element has the same argument list. I mean

// [base,stride,bound)
// [0,2,4)

Or may be there are any opportunity modify this boost::multi_array_types::index_range in order do make it accept double...

1>------ Build started: Project: HP_A.1_d_, Configuration: Debug Win32 ------
1> Main.cpp
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(15): warning C4244: 'argument' : conversion from 'double' to '__w64 int', possible loss of data
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(15): warning C4244: 'argument' : conversion from 'double' to '__w64 int', possible loss of data
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(18): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(20): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data
1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(20): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data
1> HP_A.1_d_.vcxproj -> C:all myс++HA level 9SolutionLevel 9DebugHP_A.1_d_.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Code:
#include <boostmulti_array.hpp>
#include <iostream>
typedef boost::multi_array_types::index_range range;

[Code]....

View 1 Replies View Related

C++ :: Accessing Array In A Thread (boost)

Nov 22, 2012

I was wondering if it was possible to access data from an array inside a threaded function after it has finished executing?

Take this example:

Code:
#include <iostream>
#include <boost/thread.hpp>
using namespace std;

[Code]....

After workerFunc has finished, how could I access the array arr? Is there any way to get (3,4,5,6,7) back into main()?

View 5 Replies View Related

C++ :: Unable To Get Random Numbers Using Boost In A Class

Apr 24, 2014

I have been working with and trying to understand Boost for random number generating. I've come to understand that what I want is now in the C++11 standard, but I've stuck with Boost.

What I have done is create a simple main.cpp that generated random numbers successfully. From there I wanted to create a more optimal system by separating out the random code portion to a class that can be instantiated and called on demand. My problem now is that when I call the random routine of the class I just get one number no matter how many times it's called.

I know that rapid seeding is an issue so I put the seed function of the random portion in the class's constructer so that it is only called once on the creation of a class. I also tried making it a static member, but I haven't had success with that yet either. For now though, I would simply like to get successive random values upon calling the class's random function.

class header Code: #ifndef roomGen_hpp_
#define roomGen_hpp_
#include"boost/random.hpp"
#include"main.hpp"
class
roomGen
{
private:
boost::mt19937rngDimensions;

[code].....

The main.hpp file only contains a couple of struct definitions. In main I call the class with Code: randomRooms.push_back(randRooms.createRoom()); to get back a struct with random values and push it into a vector.

I'm unsure what I'm doing wrong here to only get back a single non random number from successive calls. I have tried moving the variable creation lines from roomGen::createRoom() to the private area of the class definition, but that causes me to get a slew of undefined errors so I had to settle on putting those declarations inside the function.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved