It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I would like to insert data in a ublas::matrix but in one line the same as Matlab just like this (or something similar):
model = [
0.0685 0.6383 0.4558 0.7411 -0.7219 0.7081 0.7061 0.2887 -0.9521 -0.2553
0.4636 0.0159 -0.1010 0.2817 0.6638 0.1582 0.3925 -0.7954 0.6965 -0.7795
0 0 0 0 0 0 0 0 0 0];
If you take a look at the boost documentation, here is a list of the constructors of the matrix class http://www.boost.org/doc/libs/1_51_0/libs/numeric/ublas/doc/matrix.htm#18Members
As you can see from this documentation, it does not appear that there is a means of doing what you want at the present time, so I would suggest (unless you receive a better answer) that you populate your matrix using loops. Matlab and C++ are distinct languages so you cannot assume that you will be able to access functionality in identical manners.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I was working on a factorial program, and the program didn't work when trying to find the factorial of 1000. I think big integers are the solution; how do they work? (In either C or C++)
GMP can do bigint operations for both C and C++. The documentation on that site is a good introduction, if you use the C++ classes they behave almost exactly like built-in primitive types.
Look for the GMP. See the other question regarding this topic:
Handling very large Integers
C++ Big Integer
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to validate a text box (with max length 2) to contain only these 3 set of values.
(i) 00-99
(ii) Q
(iii) DQ
Invalid values are 1Q, 2D, QD, QQ, DD,etc etc
Alright you can use the following it will check for what you asked for its very simple and primitive regix but will work:
\d{2}|DQ|Q
If you want to better understand regular expressions the following might help:
http://msdn.microsoft.com/en-us/library/az24scfc.aspx
You can also use:
http://myregextester.com/index.php
As a tool to test your regix.
Hope that helps
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have just begun to program with C++ and come across srand(time(0)). Can anyone explain why there is a 0 in srand(time(0))?
Because that's the signature of the C time function: It requires a pointer to a location to store the time, or null. In this case 0 is the same as a literal null pointer (which means don't store the time in an alternate location).
It seeds the random number generator with the current time value so it gets a new value each time the program is run.
The 0 is equivalent to NULL. The parameter to time() takes a pointer to a time_t in which the result can also be stored.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am working on a project in school and I need to create a 160 bit value. I haven't programmed in a while so I can't figure out how I would implement this. Any help would be appreciated.
You need a library for big integers (assuming you can't just take a ready-to-use cryptographic library).
First you create a random 160-bit value, not necessarily prime. Depending on the platform, you may use /dev/random, CryptGenRandom, or some other enthropy source(s), (possible several ones, combined).
Then you increment the value in a loop, applying e.g. Miller-Rabin (pseudo-)primality test to each candidate, until you find a prime number.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
My C++ program needs to take in two arguments text or calc, those are the two functions,
How do I set this up to read in 2 input files using a map?
You need to pass command line arguments. You can find plenty or resources online. Here are a couple of examples: http://www.cplusplus.com/forum/articles/13355/ and http://msdn.microsoft.com/en-us/library/17w5ykft.aspx.