当前位置: 首页 > news >正文

网站中验证码如何做的wordpress all in one seo pack

网站中验证码如何做的,wordpress all in one seo pack,如何网站里做照片,学平面设计去哪个机构复数在数学、科学或者工程领域是很常用的,可以通过调用Apache Commons Math库来完成,也可以自己手撸。 一、使用Apache Commons Math库 这个库有多个版本,在写这篇文章时,它的最新版是2022年12月19日的4.0-beta1,构建…

复数在数学、科学或者工程领域是很常用的,可以通过调用Apache Commons Math库来完成,也可以自己手撸。

一、使用Apache Commons Math库

这个库有多个版本,在写这篇文章时,它的最新版是2022年12月19日的4.0-beta1,构建坐标是org.apache.commons:commons-math4-core:4.0-beta1,考虑到程序稳定性,我们可以使用目前开发者用得最多的版本3.6.1(2016年3月17日发布),Maven依赖如下:

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency><groupId>org.apache.commons</groupId><artifactId>commons-math3</artifactId><version>3.6.1</version>
</dependency>

示例代码如下:

import org.apache.commons.math3.complex.Complex;
public class ACMComplexDemo {public static void main(String[] args) {Complex c = new Complex(3, 5);Complex d = new Complex(2, -2);System.out.println(c);System.out.println("c = " + c.getReal() + " + " + c.getImaginary() + "i");System.out.println(c + " * " + d + " = " + c.multiply(d));System.out.println(c + " / " + d + " = " + c.divide(d));}
}

二、自己开发一个复数类

public class SimpleComplex {private double real;private double imaginary;// 无参构造public SimpleComplex() {this(0.0, 0.0);}// 双参构造,用于表示虚数public SimpleComplex(double real, double imaginary) {this.real = real;this.imaginary = imaginary;}// 单参构造,适用于实数范围public SimpleComplex(double real) {this(real, 0.0);}// 加法public SimpleComplex add(SimpleComplex other) {double real = this.real + other.real;double imaginary = this.real + other.imaginary;return new SimpleComplex(real, imaginary);}// 减法public SimpleComplex sub(SimpleComplex other) {return this.add(opposite(other));}// 乘法public SimpleComplex mul(SimpleComplex other) {double real = this.real * other.real - this.imaginary * other.imaginary;double imaginary = this.real * other.imaginary + this.imaginary * other.real;return new SimpleComplex(real, imaginary);}// 除法public SimpleComplex div(SimpleComplex other) {double real = (this.real * other.real + this.imaginary * other.imaginary)/ (other.real * other.real + other.imaginary * other.imaginary);double imaginary = (this.imaginary * other.real - this.real * other.imaginary)/ (other.real * other.real + other.imaginary * other.imaginary);return new SimpleComplex(real, imaginary);}// 获取实部public double getReal() {return real;}// 获取虚部public double getImaginary() {return imaginary;}@Overridepublic String toString() {if (this.real == 0.0) {return this.imaginary + "i";} else if (this.imaginary == 0.0) {return this.real + "";} else if (this.imaginary < 0.0 && this.real != 0.0) {return this.real + "" + this.imaginary + "i";} else if (this.imaginary == 0.0 && this.real == 0.0) {return "0.0";}return this.real + "+" + this.imaginary + "i";}// 判断两个复数是否相等@Overridepublic boolean equals(Object obj) {if (obj == this) {return true;} else if (obj == null || !(obj instanceof SimpleComplex)) {return false;}SimpleComplex tmp = (SimpleComplex) obj;return Math.abs(this.real - tmp.real) < 1e-6&& Math.abs(this.imaginary - tmp.imaginary) < 1e-6;}// 返回相反数private static SimpleComplex opposite(SimpleComplex one) {return new SimpleComplex(-one.real, -one.imaginary);}public static void main(String[] args) {// 示例用法SimpleComplex c1 = new SimpleComplex(3, 5); // 3 + 5iSimpleComplex c2 = new SimpleComplex(2, -2); // 2 - 2iSystem.out.println("c1 + c2 = " + c1.add(c2));System.out.println("c1 - c2 = " + c1.sub(c2));System.out.println("c1 * c2 = " + c1.mul(c2));System.out.println("c1 / c2 = " + c1.div(c2));}
}

显然,自己开发一个并不如Apache Commons Math做得好了,毕竟Apache的库提供了大量的运算方法,且逻辑严谨,是应用开发的首选。但执行一些简单的运算,譬如复数除法,在一定量的基础上,简单实现有一点点的性能优势。

http://www.yayakq.cn/news/91664/

相关文章:

  • 网站被降权重新做网站公司网站被抄袭
  • wordpress国内视频网站扬州网站商城建设价格表
  • 网站建设公司有哪些重要职务四川省建设厅燃气网站
  • 罗湖附近公司做网站建设哪家便宜iis中怎样配置网站绑定
  • 普陀区网站建设公司哪家好太原专业网站制作
  • j建网站湖北什么是网站建设
  • 门户网站建设和推广北京网站建设备案代理
  • 基于网站的网络营销方法有哪些网站建设需要用什么书
  • 想做个外贸网站网络营销的三大核心
  • 齐诺网站建设东莞网站建设做网站做网站和编程有关系吗
  • 网站栏目管理网站做好是需要续费的吗
  • 清远市建设局网站公司注册资金需要实际缴纳吗
  • 南京网站建设润洽做财经比较好的网站有哪些
  • 青岛上市公司网站建设专业做装修设计的网站
  • 手机上能搭建网站吗企业 官网
  • 中小企业网站建设公司网页免费代理
  • 公司网站开发 中山企业画册设计排版
  • 做绒毛鉴定网站100个万能营销方案
  • 常州做网站多少钱旧网站如何优化
  • 长沙企业网站模板高端网站设计报价
  • 企业网站规划与建设英文设计网站
  • 资讯网站如何做聚合长沙创建一个网站需要多少钱
  • 仿制网站建设今天的新闻联播主要内容
  • 网站建设初期 该如何推广广州力洋建设工程有限公司
  • 网站菜单栏代码中国建设银行电话95533
  • 设计网站设计原则erp外贸管理系统
  • 网站开发公司会在最后面加上公司苏州网络科技公司建网站
  • 建设局网站查询个人信息外国出名的设计网站
  • 网站建设 有道翻译广州编程培训机构
  • 网站设计的价格wordpress图片分页插件下载