mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2022-12-23, 00:31   #45
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

23×19×41 Posts
Default

Quote:
Originally Posted by charybdis View Post
divisors() can take a factorization matrix as input.
D'oh!

I should have just tried that! I should have realized it was very likely to work.

[tries an example, and it does indeed work]

Thank you!
Dr Sardonicus is online now   Reply With Quote
Old 2022-12-23, 00:55   #46
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

5×17×19 Posts
Default

Once you factored n, you could add the primefactors, so then a new numdiv/divisors or any such functions when you know factor() would be called will be much faster.
Code:
? ?addprimes
addprimes({x=[]}): add primes in the vector x to the prime table to be used in trial 
division. x may also be a single integer. Composite "primes" are NOT allowed.
But if you would add too "many" factors, then it could actually slow down these calls, because the code goes through the added primes list (until n is not factorised). Really helpful, used it in real codes.
R. Gerbicz is offline   Reply With Quote
Old 2023-01-12, 15:13   #47
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

449610 Posts
Default

How do I increase threadsizemax before running gp under Linux? I.e. what do I need to put in $HOME/.gprc?
paulunderwood is offline   Reply With Quote
Old 2023-01-25, 07:50   #48
bur
 
bur's Avatar
 
Aug 2020
79*6581e-4;3*2539e-3

659 Posts
Default

To have a progress bar, it would be useful to output a string to the same line, overwriting the previous output. Is that possible? Maybe by using "delete" characters as print() arguments?
bur is offline   Reply With Quote
Old 2023-01-25, 11:33   #49
Neptune
 
Neptune's Avatar
 
"Martin Hopf"
Jul 2022
Germany

2·3·7 Posts
Default

Quote:
Originally Posted by bur View Post
To have a progress bar, it would be useful to output a string to the same line, overwriting the previous output. Is that possible? Maybe by using "delete" characters as print() arguments?
This should work with printf():
Code:
printf(" ... %c", ... , 13)
with decimal '13' means the ASCII code for carriage return.


For example counting primes up to 10^9 and get progress information in a fixed line would look like this:
Code:
c=0;s=1e9;forprime(p=2,s,c++;if(c%10^5==0,printf(" %3.1f%%  %c",p/s*100,13)));c
Of course frequently calling printf() will slow down the loop, so in this example it is done only after every 100,000-th prime.

Last fiddled with by Neptune on 2023-01-25 at 12:13 Reason: extension
Neptune is offline   Reply With Quote
Old 2023-01-25, 12:45   #50
Neptune
 
Neptune's Avatar
 
"Martin Hopf"
Jul 2022
Germany

528 Posts
Default

A carriage return is also possible with:
Code:
print1(strchr(13))
Neptune is offline   Reply With Quote
Old 2023-01-25, 15:34   #51
bur
 
bur's Avatar
 
Aug 2020
79*6581e-4;3*2539e-3

659 Posts
Default

Thanks, that seems to be what I was looking for!
bur is offline   Reply With Quote
Old 2023-01-26, 04:44   #52
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

23·293 Posts
Default

Very nice Neptune. Thank you. I too have been looking for a carriage return without the linefeed to no avail.
I have vague memory of cls in the old DOS having a similar functional use. I checked it just now and it works too:

Code:
\\ To Clear the Screen
system("cls")
\\
Note:
* Not sure if it would work on a Linux system.

Adding your code to my library. Thanks again.

Last fiddled with by a1call on 2023-01-26 at 04:50
a1call is online now   Reply With Quote
Old 2023-01-26, 08:15   #53
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

119016 Posts
Default

Quote:
Originally Posted by a1call View Post
Very nice Neptune. Thank you. I too have been looking for a carriage return without the linefeed to no avail.
I have vague memory of cls in the old DOS having a similar functional use. I checked it just now and it works too:

Code:
\\ To Clear the Screen
system("cls")
\\
Note:
* Not sure if it would work on a Linux system.
On Linux it is the clear command.

Cross platform: print("\e[H\e[2J")

Last fiddled with by paulunderwood on 2023-01-26 at 08:20
paulunderwood is offline   Reply With Quote
Old 2023-01-26, 08:52   #54
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

234410 Posts
Default

Noted and filed to my library. Thank you.
a1call is online now   Reply With Quote
Old 2023-01-26, 13:06   #55
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

149016 Posts
Default

I've been using printf "Text, text, text. \r" in my bash scripts in linux. Less for me to remember, although from my Windows days I can still remember cr = 13.
EdH is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
LLL in GP/Pari paul0 Programming 2 2015-11-17 13:04
Card Tricks davar55 Hobbies 11 2013-05-27 14:28
How To Evaluate SNFS Polynomial Tricks? wblipp Factoring 4 2011-04-15 16:22
Tool Tips clobbered by Prime95 (on Win2K) Bob Stein Information & Answers 1 2008-04-11 17:52
Help/Tips on Buiding Computer? Unreg Hardware 6 2004-09-18 18:19

All times are UTC. The time now is 14:06.


Wed Feb 8 14:06:51 UTC 2023 up 174 days, 11:35, 1 user, load averages: 0.72, 0.85, 0.86

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔