473,796 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GMP: Cannot operate on vector<mpz_t>

#include <gmp.h>

vector<mpz_t> v_bigints; v_bigints.resiz e(20);

This fails.

error: ISO C++ forbids casting to an array type '__mpz_struct[1]' (GCC
on a G4)

What's wrong with this? (GMP mailing lists were closed today, sorry).
Jul 23 '05 #1
3 5155
Richard Cavell wrote:

#include <gmp.h>

vector<mpz_t> v_bigints; v_bigints.resiz e(20);

This fails.

error: ISO C++ forbids casting to an array type '__mpz_struct[1]' (GCC
on a G4)

What's wrong with this? (GMP mailing lists were closed today, sorry).


As has been told otherthread, the type mpz_t is defined in a way which
makes this impossible. It is a 'clever hack' to avoid a few keystrokes.
(So much for clever hacks :-)

You could try using __mpz_struct directly.

vector < __mpz_struct > v_bigints;
--
Karl Heinz Buchegger
kb******@gascad .at
Jul 23 '05 #2
On Fri, 18 Feb 2005 22:28:52 +1100, Richard Cavell
<ri***********@ mail.com> wrote:
#include <gmp.h>

vector<mpz_t> v_bigints; v_bigints.resiz e(20);

This fails.

error: ISO C++ forbids casting to an array type '__mpz_struct[1]' (GCC
on a G4)

What's wrong with this? (GMP mailing lists were closed today, sorry).


See my reply in thread "Cannot 'new' a GMP object", Message-ID

<sl************ ******@ccserver .keris.net>

mpz_t is defined as a 1-element array, to make using the C GMP functions
easier, which blows the C syntax for containers and new. Plus it is
risky, since you will have to ensure that each of the elements is
correctly initialised and cleared whenever you resize the vector
otherwise you will get momory leaks. The C++ class versions are much
easier to us.

Chris C
Jul 23 '05 #3
On 19/2/05 12:18 AM, Karl Heinz Buchegger wrote:
vector < __mpz_struct > v_bigints;


That doesn't work either.

Thanks to everyone for their help.

For the record, my solution is like this:

mpz_t myMPZArray[3000]; // This works

for (int i=0; i<NumberOfMPZNe eded; i++)
{
// Initialize and operate on myMPZArray[i];
}

Which wastes up to 3000 * sizeof (mpz_t) bytes of RAM and means I have
to change a constant in my program to get more than 3000, but it does
work...
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2764
by: Alexander Skwar | last post by:
Hello! I'm having problems getting PHP 4.3.3RC4 successfully to install on my HP-UX 11.00 server. After a (successfull?) compile, "make install" errors out with this error message: #############################################################################################################
0
1495
by: Jasper | last post by:
Hello Perlers, I followed the directions on how to install GNU GMP for windows (below and on the URL) http://www.cs.nyu.edu/exact/core/gmp/ and I don't notice any performance gain..in Perl one is supposed to place this in the code and then apply variables to BigFloat syntax : use Math::BigFloat lib => 'GMP'; But I notice zero difference in calculation speed..I realize this is a python board, but I am wondering if there is anyone who...
0
1607
by: Jasper | last post by:
Hello, I am truly stuck after several failed attempts on Win XP ..can anyone please assist here. I was told "activestate perl is compiled by MS visual c++, it cannot use library files compiled under cygwin. you can either use perl in cygwin with our cygwin version gmp library in that webpage, or use activestate perl with our gmp library which is also compiled using MS visuall C++ (the information can be found in the same page:
0
1812
by: anonymous | last post by:
I cannot compile LiDIA mathematical library version 2.1pre5 with the gmp 4.1.2 multiprecision library because the gcc compiler ver 3.2.2 20030222 Red Hat Linux 9 complains about some structures in the gmp.h header file: /usr/local/include/gmp.h:2073: declaration of C function `std::ostream& operator<<(std::ostream&, const __mpq_struct*)' conflicts with /usr/local/include/gmp.h:2072: previous declaration `std::ostream&...
1
6999
by: Jasper | last post by:
Hello c++'ers, I followed the directions on how to install GNU GMP for windows (below and on the URL) http://www.cs.nyu.edu/exact/core/gmp/ and I don't notice any performance gain..in Perl one is supposed to place this in the code: use Math::BigFloat lib => 'GMP'; But I notice ZERO difference in calculation speed..I realize this is a C++ board, but I am wondering if there is anyone who knows how to verify installation, or any tricks to...
4
1567
by: neehakale | last post by:
I m trying to write an event for the CheckedListBox...here m using foreach loop syntsx: (type identifier in expression) but it is giving error :foreach statment cannot operate on variables of type object. because object does not contain a definattion for GetEnumerator or it is inaccessible private void btnOK_Click(object sender, System.EventArgs e) {
0
3312
by: dot | last post by:
I spent a few headache filled days trying to use GMP on windows (XP pro) I finally got it to work and since I found little help on the Web I thought someone might find what i did useful. Creating an environment suitable for GMP programming. 1) Create 'cygwin' environment (see below) 2)add GMP to the cygwin directory (see below)
2
10013
boss32178
by: boss32178 | last post by:
Ok I get this error when i try to run the web app. foreach statement cannot operte on variables of type 'object' does not contain a public definition for 'GetEnumerator' here is the code #region Number String public string MyNum(System.Object MyString) { string temp; foreach (string mylet in MyString)
0
994
by: ikilobo | last post by:
i want to representation the large random bit to operate the arithmetic, like this example input n=10, then 10 random bit has create A= B= i want to divide the array to any part like A=,]
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.