Skip to content

Complex Complete Library, a feature rich complex numbers library for Kotlin and Java

License

Notifications You must be signed in to change notification settings

KatieUmbra/CompxCLib

Repository files navigation

Repository Icon

CompxCLib

Complex Complete Library

A complete library for all of your complex needs!


contributors forks stars issues license pull requests

Table of contents
  1. About
  2. Installation
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgements

About

Graph of a complex function Graph of a complex function Graph of a complex function

these images were generated using Processing.

CompxCLib is a library targeted at everyone that needs to work with complex numbers in a straightforward and elegant manner, utilizing the features of the Kotlin language to make it accessible and simple.

but why not use one of the many libraries out there? compxclib has unique features that make using complex numbers a breeze.

Here are some of the unique features that Compxclib has:

  • Main intuitive complex number class, with plenty of operator extensions and infix pow function (kotlin exclusive)
  • Number operator extensions
  • Trig, exp, and other kinds of operations that are well optimized
  • An expression parser to quickly evaluate mathematical expressions that use complex numbers.

Inspiration

The reason I started working on this library was that I'm in love with complex algebra and I wanted to have a simple-to-use tool in order to create interesting and aesthetically pleasing simulations.

Tools used

These were some of the tools I used to build this project (except processing, that was used to make the graphics in this document)

  • Gradle Logo
  • Processing Logo
  • IntelliJ IDEA logo
  • ShadowJar on Github
  • Kotlin Logo

Getting Started

Installation

repository

Maven
pom.xml
<dependency>
  <groupId>dev.kaytea</groupId>
  <artifactId>compxclib</artifactId>
  <version>1.2</version>
</dependency>
Gradle
build.gradle
dependencies {
    //other dependencies...
    implementation 'dev.kaytea:compxclib:1.2'
}
Gradle kotlin
build.gradle.kts
dependencies {
  //other dependencies...
  implementation("dev.kaytea:compxclib:1.2")
}

Examples

parsing user input to a complex number
import compxclib.ComplexNumber;
import compxclib.parser.Parser;
import java.util.Scanner;

public class App{
  private static final Scanner scanner = new Scanner(System.in);

  private static void calculate() {
    String input = scanner.nextLine();
    Parser parser = new Parser(input);
    ComplexNumber result = parser.parse();
    System.out.println(input +" = "+ result);
  }

  public static void main(String[] args) {
    System.out.println("Introduce an expression");
    calculate();
  }
}
run multiple operations efficiently
import compxclib.ComplexNumber
import compxclib.functions.sin

fun main() {
  val (width, height) = Pair(1920, 1080)
  val results = Array(height) { Array(width) { ComplexNumber(0,0) } }
  for (i in 0 ..< height) {
    for (j in 0 ..< width){
      val currentNumber = ComplexNumber(height, width)
      val sinOfCurrentNumber = sin(currentNumber)
      results[i][j] = sinOfCurrentNumber
    }
  }
  println(results)
}

Roadmap

  • Adding a fully functioning complex number class
  • Handling typical functions such as exp(x) or log(x)
  • Refractor codebase and optimize
  • Handling extra functions
    • Trig functions
    • Hyperbolic functions
  • Adding a parser
    • Parser returns values
    • Parser returns functions
  • Examples inside the documentation

Contributing

Contributing is what makes open source projects so magical, and it unites the community. if you want to suggest a feature then you could either

  • Create a new issue with the "Suggestion tag"
  • Create a pull request:
    1. Fork the Project
    2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
    3. Commit your Changes (git commit -m 'Add some AmazingFeature')
    4. Push to the Branch (git push origin feature/AmazingFeature)
    5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

You can contact me with the name "Katherine"

Acknowledgements