java的演算法庫
java中有個math類。裡面就有許許多多的演算法。下載一個jkd api慢慢看把,多的你眼花繚亂
軟體包 java.math
提供用於執行任意精度整數演算法 (BigInteger) 和任意精度小數演算法 (BigDecimal) 的類。
Ⅱ JAVA有哪些適合進行數值計算,數據分析/機器學習的庫
直接搜關鍵詞:numerical computations in java
1、https //en wikipedia org/wiki/Java_programming_language
Apache Commons, is an open-source for creating reusable Java components. It has numerical packages for linear algebra and non-linear optimization.
ND4J is an open-source library that supports n-dimensional (ND) arrays, similar to NumPy. It runs on distributed GPUs or CPUs cross-platform. It supports thedeep learning library Deeplearning4j.
Colt provides a set of Open Source Libraries for High Performance Scientific and Technical Computing.
Efficient Java Matrix Library (EJML) is an open-source linear algebra library for manipulating dense matrices.
JAMA, a numerical linear algebra toolkit for the Java programming language. No active development has taken place since 2005, but it still one of the more popular linear algebra packages in Java.
Jblas: Linear Algebra for Java, a linear algebra library which is an easy to use wrapper around BLAS and LAPACK.
Parallel Colt is an open source library for scientific computing. A parallel extension of Colt.
DataMelt, an open-source Java libraries for numerical calculations, data I/O and visualization of scientific results. Used together with Jython.
JMSL Numerical Libraries, is a comprehensive set of mathematical, statistical, data mining, financial and 2D/3D charting classes.
Matrix Toolkit Java is a linear algebra library based on BLAS and LAPACK.
OjAlgo is an open source Java library for mathematics, linear algebra and optimisation.
exp4j is a small Java library for evaluation of mathematical expressions.
la4j is a tiny Java library and it provides linear algebra primitives and algorithms.
Universal Java Matrix Package UJM is a Java library which provides implementations for sparse and dense matrices, as well as linear algebra calculations such as matrix decomposition, inverse, multiply, mean, correlation, standard deviation, etc.
Java Matrix Library A thoughtfully designed Java library for dealing with Matrices ( Matrix Theory ). Simple, Intuitive and Flexible. The library revolves around a Matrix interface. Operations are thoughtfully distributed. Not guilty of exposing all-in-one Matrix class.
JDistLib Java Statistical Distribution Library is a Java package that provides routines for various statistical distributions. A manual translation of distributions provided by R statistical package.
SuanShu by Numerical Method Inc. is a large collection of numerical algorithms including linear algebra, (advanced) optimization, interpolation, Markov model, principal component analysis, time series analysis, hypothesis testing, regressions, statistics, ordinary and partial differential equation solvers.
2、Java Numerics: Main
Apfloat is a arbitrary precision floating-point arithmetic package.
ArciMath BigDecimal is an extension of java.math.BigDecimal based on IBM's Java Specification Request.
Colt is a free Java toolkit containing data structures and utilities intended for high performance computing.
Commons-Math The Jakarta Mathematics Library is is a library of lightweight, self-contained mathematics and statistics components addressing the most common problems not available in the Java programming language.
Drej, an open-source Java library for linear and non-linear least-squares regression and regularized least-squares classification.
A translation of the ELEFUNT Elementary Functions Testing Package has been ported to Java. The collection also contains extensions to java.lang.Math and new classes for numeric output formatting.
IBM's AlphaWorks contains several tools of interest, including
library of correctly rounded elementary functions intended for use with Java.
Ninja, a set of classes for numerically intensive Java, including complex, multidimensional arrays, and the BLAS. (RETIRED)
Java Numerical Toolkit (JNT)
Special functions including Bessel functions, Chebyshev series.
Zero root finder
Random Number generators for uniform and normal sequences of floating point numbers and long integers.
Java Ultimate Math Package, a framework for arbitrary precision computations.
The Java3D effort proced a matrix package for use in graphics.
JMSL, a collection of mathematical, statistical and charting classes, written in 100% Java, marketed by Visual Numeric, Inc. Includes linear algebra, zero finding, splines, ordinary differential equations, linear programming, nonlinear optimization, FFTs, special functions, regression, ANOVA, ARMA, Kalman filters.
JLargeArrays, a pure Java library of one-dimensional numeric arrays that can store up to 2^63 elements.
JSci, a set of Java packages for linear algebra, statistics, wavelets. Includes chart/graph components and a partial MathML DOM implementation.
jScience contains packages for numerical linear algebra, for computing with units (e.g., kg., sec.), and other utility operations.
Jspline+ is a spline approximation library for Java developed at the Institute of Computational Mathematics and Mathematical Geophysics (RAS) in Novosibirsk. It contains classes for univariate and multivariate spline approximation on scattered meshes, as well as core matrix and linear system solution classes.
JTransforms, The first open source, multithreaded FFT library in pure Java.
Koalog Constraint Solver is a commercial Java library for solving combinatorial optimization problems using Constraint Programming or Local Search.
Least Squares Software markets the jCrunch[tm] class libraries for numerical computing.
mpjava is a Java implementation of David Bailey's Fortran-based multiprecision package. The package performs multi precision floating point arithmetic with arbitrary precision level. It takes advantage of Java's inheritance facility to provide smooth transition from primitive arithmetic types.
netlib has a small collection of Java numerical classes.
A Numerical Library in Java for Scientists and Engineers, a book published by CRC Press, contains a CD-ROM with translation into Java of the library NUMAL (NUMerical proceres in Algol 60).
Ⅲ java演算法
貌似是查找連續數和的問題吧
首先把和為N的所有可能連續數找出來,判斷數字個數是否大於L
Ⅳ JAVA演算法
上邊的演算法不對,如果是那樣最後結果就是1
。應該是用鏈表來做,每個鏈表項有兩個內容一個是指向下一個鏈表項的指針,另一個記錄最開始的id number
如 public class array{
int id;
array next;
}
在public static void main裡面初始化鏈表
然後判斷id % 3==0 出圈的就從鏈表中刪除,如此循環最後剩的那個還在鏈表中的id號就是答案。
Ⅳ 求個JAVA的演算法給思想也行
http://hi..com/peiwenlin/blog/item/6e983b465c40e40e6b63e5de.html
也是在網上找的,其實沒看懂,呵呵。
個人覺得應該先算出每個工作的每小時效益
工作 利益 時間 利益/小時
Compact 10,000 20 500
Sedan 20,000 30 666.6666667
Wagon 30,000 35 857.1428571
Offroad Motorcycle 12,000 15 800
Road Motorcyle 10,000 12 833.3333333
一定是先盡量干單位利益最多的,剩下的時間干次多的,以此類推。
按照上面的演算法,最後的結論是5個wagon和2個road motorcycle,共199小時,獲利$170,000
Ⅵ java類有直接調用pollard_rho演算法的庫方法么
暫時沒有封裝好的第三方庫支持pollard_rho演算法,只能自己編程實現。
Ⅶ JAVA 實現演算法
package huda.laogao.ON_20121216;
import java.util.*;
public class GetEquation {
ArrayList<Integer> params = null;// 進行加減的數,長度設為n
int result = 0;// 結果
public GetEquation(ArrayList<Integer> params, int result) {
this.params = params;
this.result = result;
}
public void run() {
int size = params.size();
if (size == 1) {
if (params.get(0) == result)
System.out.println(result + "=" + result);
else
System.out.println("Invalid");
return;
}
int[][] matrix = getMatrix(size - 1);
int m = matrix.length;// 行數
int count = 0;// 記錄符合結果的組合數
for (int i = 0; i < m; i++) {
int now = params.get(0);// 進行加減的結果,初始為第一個值
// 從第二個數開始進行加或減,加的話就相當於該數乘上1,然後加到結果上,
// 減的就相當於該數乘上-1,然後加到結果上
for (int j = 1; j < size; j++) {
now += matrix[i][j - 1] * params.get(j);
}
// System.out.println(now);
// 判斷結果
if (now == result) {
count++;// 組合數加1
System.out.print(params.get(0));
for (int j = 1; j < size; j++) {
if (matrix[i][j - 1] == 1)
System.out.print("+" + params.get(j));
else
System.out.print("-" + params.get(j));
}// for j
System.out.println("=" + result);
}// if
}// for i
if (count == 0)
System.out.println("Invalid");
}
public int[][] getMatrix(int n) {
int m = (int) Math.pow(2, n);
int matrix[][] = new int[m][n];
for (int i = 0; i < n; i++) {
int num = (int) Math.pow(2, i + 1);
// 總共分 2^(i+1)塊,如i=0,即該矩陣的第一列,可分為2塊,上一塊取1,下一塊取-1
int size = (int) Math.pow(2, n - i - 1);
// 每塊的大小為2^(n-i-1),如n=3,i=0,每塊的大小為4,即前4個為1,後4個為-1
int flag = 1;// 先為+
for (int j = 0; j < num; j++) {
for (int k = 0; k < size; k++) {
matrix[k + j * size][i] = flag;
}
flag *= -1;
}
}
return matrix;
}
public void print(int[][] matrix) {
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
System.out.print(matrix[i][j] + "\t");
}
System.out.println();
}
}
public static void main(String args[]) {
ArrayList<Integer> params = new ArrayList<Integer>();
params.add(1);
params.add(2);
params.add(3);
params.add(4);
int result = 10;
GetEquation ge = new GetEquation(params, result);
ge.run();
}
}
運行結果為:1+2+3+4=10
註:難點為獲取加減矩陣,可輔助print()函數幫助理解
望採納
Ⅷ java十大演算法
演算法一:快速排序演算法
快速排序是由東尼·霍爾所發展的一種排序演算法。在平均狀況下,排序 n 個項目要Ο(n log n)次比較。在最壞狀況下則需要Ο(n2)次比較,但這種狀況並不常見。事實上,快速排序通常明顯比其他Ο(n log n) 演算法更快,因為它的內部循環(inner loop)可以在大部分的架構上很有效率地被實現出來。
快速排序使用分治法(Divide and conquer)策略來把一個串列(list)分為兩個子串列(sub-lists)。
演算法步驟:
1 從數列中挑出一個元素,稱為 "基準"(pivot),
2 重新排序數列,所有元素比基準值小的擺放在基準前面,所有元素比基準值大的擺在基準的後面(相同的數可以到任一邊)。在這個分區退出之後,該基準就處於數列的中間位置。這個稱為分區(partition)操作。
3 遞歸地(recursive)把小於基準值元素的子數列和大於基準值元素的子數列排序。
遞歸的最底部情形,是數列的大小是零或一,也就是永遠都已經被排序好了。雖然一直遞歸下去,但是這個演算法總會退出,因為在每次的迭代(iteration)中,它至少會把一個元素擺到它最後的位置去。
演算法二:堆排序演算法
堆排序(Heapsort)是指利用堆這種數據結構所設計的一種排序演算法。堆積是一個近似完全二叉樹的結構,並同時滿足堆積的性質:即子結點的鍵值或索引總是小於(或者大於)它的父節點。
堆排序的平均時間復雜度為Ο(nlogn) 。
演算法步驟:
創建一個堆H[0..n-1]
把堆首(最大值)和堆尾互換
3. 把堆的尺寸縮小1,並調用shift_down(0),目的是把新的數組頂端數據調整到相應位置
4. 重復步驟2,直到堆的尺寸為1
演算法三:歸並排序
歸並排序(Merge sort,台灣譯作:合並排序)是建立在歸並操作上的一種有效的排序演算法。該演算法是採用分治法(Divide and Conquer)的一個非常典型的應用。
演算法步驟:
1. 申請空間,使其大小為兩個已經排序序列之和,該空間用來存放合並後的序列
2. 設定兩個指針,最初位置分別為兩個已經排序序列的起始位置
3. 比較兩個指針所指向的元素,選擇相對小的元素放入到合並空間,並移動指針到下一位置
4. 重復步驟3直到某一指針達到序列尾
5. 將另一序列剩下的所有元素
Ⅸ java中的演算法,一共有多少種,哪幾種,怎麼分類。
就好比問,漢語中常用寫作方法有多少種,怎麼分類。
演算法按用途分,體現設計目的、有什麼特點
演算法按實現方式分,有遞歸、迭代、平行、序列、過程、確定、不確定等等
演算法按設計范型分,有分治、動態、貪心、線性、圖論、簡化等等
作為圖靈完備的語言,理論上」Java語言「可以實現所有演算法。
「Java的標准庫'中用了一些常用數據結構和相關演算法.
像apache common這樣的java庫中又提供了一些通用的演算法
Ⅹ Java演算法
public class wen {
public static void main(String []args)
{
int i ,j;
int sum=0;
for (i=1;i<=3;i++){
for(j=1;j<=3;j++)
{
sum+=j;
}
}
System.out.println(sum);
}
}
這樣才對,一樓的不對。可以運行一下實驗一下