-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move MpiPartitionGeneratorRunner to test scope, align method names
- Loading branch information
1 parent
e8ba884
commit 0a64556
Showing
4 changed files
with
101 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/test/java/de/tilman_neumann/jml/partitions/MpiPartitionGeneratorRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project. | ||
* Copyright (C) 2018-2024 Tilman Neumann - tilman.neumann@web.de | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program; | ||
* if not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.tilman_neumann.jml.partitions; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.SortedSet; | ||
|
||
import org.apache.logging.log4j.Logger; | ||
import org.apache.logging.log4j.LogManager; | ||
|
||
import de.tilman_neumann.util.ConfigUtil; | ||
|
||
/** | ||
* MPI partition generator runner. | ||
* @author Tilman Neumann | ||
*/ | ||
public class MpiPartitionGeneratorRunner { | ||
|
||
private static final Logger LOG = LogManager.getLogger(MpiPartitionGeneratorRunner.class); | ||
|
||
private static final boolean DEBUG = false; | ||
|
||
/** | ||
* Test | ||
* @param args ignored | ||
*/ | ||
public static void main(String[] args) { | ||
ConfigUtil.initProject(); | ||
|
||
while(true) { | ||
String input; | ||
try { | ||
LOG.info("\nPlease insert comma-separated parts of multipartite number:"); | ||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | ||
String line = in.readLine(); | ||
input = line.trim(); | ||
LOG.debug("multipartite number input = [" + input + "]"); | ||
} catch (IOException ioe) { | ||
LOG.error("io-error occurring on input: " + ioe.getMessage()); | ||
continue; | ||
} | ||
try { | ||
Mpi q = new Mpi_IntegerArrayImpl(input); | ||
long start = System.currentTimeMillis(); | ||
long count = MpiPartitionGenerator.numberOfPartitionsOf(q); | ||
LOG.info(q + " has " + count + " partitions (computed in " + (System.currentTimeMillis()-start) + "ms)"); | ||
if (DEBUG) { | ||
SortedSet<MpiPartition> partitions = MpiPartitionGenerator.partitionsOf(q); | ||
LOG.debug(q + " has " + partitions.size() + " partitions: " + partitions); | ||
} | ||
} catch (NumberFormatException nfe) { | ||
LOG.error("input " + input + " is not a multipartite integer"); | ||
} | ||
} // next input... | ||
} | ||
} |