Bill Allombert on Tue, 06 Feb 2024 00:54:30 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: What explains this discrepancy in concat()?
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: What explains this discrepancy in concat()?
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Tue, 6 Feb 2024 00:54:19 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1707177262; c=relaxed/relaxed; bh=XzCQizu2wQ6ehFrSOYFP0lB4uRawl13ZKIo02ZZ8JRk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=svT4pzvATqWZW6tmhAhrKcVkcNc8VKwuoiECAKxiqIAWO9GY+icP/aZg7ejnpJGQnI59ACqxYo1xhyQBVAeiOp9EfXvBApynQLOQMJpho7z7T7//T1QkjQWx0IjhaUYrhZbOP1HD89Yy8Uc382GJnpStxUzQyQtInETqGIIz+m9a2B/qY1Ce2yM/yt2khn7A383XYJzfAACi2pEA+tQkEykAUOWhoOcyAIYw+e2+SB2WJF8I8cuD6mCkE1KvuGv08Yblh4GHA56Ob259SlfIo6LvBrGhxEpxYDj31Z6gbYF1ZRsPsuXUvH7W87ZsBlNWF9t3uzlPAweEt9u/3/kCx2TPeVeMFg3G6kp2HdSu1NRRzdxetJn9nlq5dT2k7lDwmsuw+vX1mysaEEFXpf8NniHKsk/eg2mUQynIWZyp79O3ex2Coneizvutv17LtFauVmzNDrOustp45200c/VO5CeKjL+QcXXoDmS5vCFgf/1k/VmgsmXGtXuvg3k8aVp1UKrjyoaqSz3s26V7TRLmz57iYm/tB8YaA4UybGz3D+Dw0zBYi+SqJlC/I2gCEUEzbOzwUSm5hbtDoTdao7Mz5rtefKp5QFaH7giLfnBhDwdixvSHtDpqLK4M0HERsuXKfAwF7B9/T1BoiIP2Eqb4bhMo3tc+stLQY+VDTmkGF6c=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1707177262; cv=none; b=taCDNgHuFFnEZ9jj9pO5hMStZkqAIOYtN9CcG6rk3Hvk2Ri4aLimYj766LXIF6Iun2I8gwVAPZCM1w81Hv1bkBdpuT1FIG8b+GoqZJ9qQsZldN2a8N+mF3LoVnp1SwgYpri9La8NyNNW2YpP1mDiKaZMaQ1k4GbXvsvBomjlPZlAs7EpXljEEGdoiTgPSEpAV7evexpzYNBguyglzHhPCUfpa19+3f9QwwXB7RHinC1BxN0YELfEpH6WSjsnah3Zf+63goCW9ZVF3Rrods9n1lLYgT6esjoLd86kWtTzExuVg5ucOyUi1xqxinNbLBygNciezdCX8r8zdPX35Ppn8Z8ztYmvMfrIsYG2QSqUDtPMRWfHu/rT8qe2z9Y+vU9yQ9Pwg7GNUo9m/TPnn52b/7rckQcAE17kRYFvYPIG7LBGlDnEeHqrHb6/3aHi9dg3GDLJ629eBCWcp2gk4NhePXR4MCQfbwfwWpO0DYoJ2i3Xn9S03ZetWlKhSKASigQSgVHm4DMf++Gj3JjHiq5KP6NqZJA8kGnxhXVGPY4ek3cztwzxtzU38w6Edl7t3E8rG3sIEpUEZeXPSdOQxRq4LswxsbScyl7aZ+gnIkZFIEAgNTlVTQbDupP6Vk0juwjZJA1lI/9QOr5+WgjgD5HyLUp/Ytpi0yqRekOiDik0rsM=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Delivery-date: Tue, 06 Feb 2024 00:54:30 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1707177262; bh=XzCQizu2wQ6ehFrSOYFP0lB4uRawl13ZKIo02ZZ8JRk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=mG/CrPE+yG/hSuPvCQpgL7w5o/NtCIQgCPvo2Un/TNKJinPI7sCLr8MIcttKFaDX4 2A94Lm2yFDUj2J+Y445XJ63LYLKM7/szfSY4ZVa9dqOH3N51YxOp8VsrU6wxAmIxAS VBvnO1Uqkxv5HSLm5i7JeogMrcn0Y3vJVlhA/de7BPUB/xNSTnBD0jU3h9ZqVQDyMD C1kQ2Bge4P0cMlhBlKYS9XMbhzo6Al/tti64793B3HFfGC14Js5ST4jZ+Xa+7hX2Cc mVT3q53jgpPPiFPvjemBV2bRqabFqyKlvdGLL5uj6y8/uQ/TWnhtCFy0DiBAaHa3Cx EaDpvecpPLC+o8GO9LobmhmdAVRj2Jrnvq3IaHNrBk1maMZduc6Fi0LJX3IDbO6Le7 AAihffwvhuDQR9GEdkLih0vzyg0h2iEycZBfAl8KOd50pbPfX9a8NTB+v4MsBe8Iov kKUduJWBUe0MiXOcNrX97oNAUCeWX4qxXsYdkevSLVmALuxuNSbjjcrxiuktBAVGnd A7pMfYJOYobF4dFEVSYjko1H1+BiFuB20OAK6JuXyFx3FqILHdNS1i7ydXs/epnAXT Kexpl/xbIaWNo5JFG1eEg52i1w4BBSmAnM0Xls2jmV6+bgrfrDDydq0pWTHIDynDbd eBy7bMErYLTNz5JOg+FzbB7E=
- In-reply-to: <CAEdMSjc7+R-JZFszYdLGv26oZv59rNX7TnO4HP+t8ufkVv67hg@mail.gmail.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <35a59aed-657d-444a-a516-11568c9e3479@gmail.com> <ZcFZDCDpmgnhxcg4@seventeen> <CAEdMSjc7+R-JZFszYdLGv26oZv59rNX7TnO4HP+t8ufkVv67hg@mail.gmail.com>
On Tue, Feb 06, 2024 at 10:29:57AM +1100, Joe Slater wrote:
> I have a large matrix, the cells of each may be filled by a vector. It
> seems that concat() works very differently when called within a function:
>
> > k(m,c=1)=concat(m[,c])
> %62 = (m,c=1)->concat(m[,c])
> > s1=k(a,15);
> *** Warning: increasing stack size to 400000000.
> *** Warning: increasing stack size to 800000000.
> time = 203 ms.
> > s2=concat(a[,15]);
> time = 78 ms.
> > s1==s2
> time = 32 ms.
> %65 = 1
>
> What's going on here?
s1=k(a,15) requires GP to copy 'a' in case k() modifies it!
(imagine k is k(m,c=1)=a=0;concat(m[,c]). m[,c] would fail
because at this point m=0!).
There are two possible work-around:
1/ declare 'a' with my() so that k cannot possibly modify a
since it is not in scope of k.
2/ use k(~a,15) which skips the copy.
You get a warning 'compiler generates copy' if default(debug) is not 0:
? k(m,c=1)=concat(m[,c]);
? \g1
debug = 1
? a=mathilbert(500); k(a,15);
*** Warning: compiler generates copy for `a'.
*** mathilbert: Warning: increasing stack size to 16000000.
*** Warning: increasing stack size to 32000000.
*** Warning: increasing stack size to 64000000.
? my(a=mathilbert(500)); k(a,15);
*** mathilbert: Warning: increasing stack size to 16000000.
? a=mathilbert(500); k(~a,15);
*** mathilbert: Warning: increasing stack size to 16000000.
Cheers,
Bill.