Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to solve quadratic equations #398

Merged
merged 4 commits into from
Mar 27, 2024
Merged

Add function to solve quadratic equations #398

merged 4 commits into from
Mar 27, 2024

Conversation

hamirmahal
Copy link
Contributor

closes #397.

@triallax
Copy link
Contributor

Since we're returning a string now, might as well implement the function directly in Numbat (as shown in #397 (comment))?

@triallax
Copy link
Contributor

Also can you change the commit message to "Add function to solve quadratic equations"?

@triallax triallax mentioned this pull request Mar 13, 2024
@hamirmahal hamirmahal changed the title feat: functionality for quadratic equation Add function to solve quadratic equations Mar 13, 2024
@hamirmahal
Copy link
Contributor Author

Since we're returning a string now, might as well implement the function directly in Numbat (as shown in #397 (comment))?

Either way is fine. Feel free to close this if this isn't something you want to add.

@triallax
Copy link
Contributor

triallax commented Mar 13, 2024

I'm fine with adding it to Numbat myself (no idea about @sharkdp), it's just that I don't see a good reason to do it via FFI'ing to Rust instead of implementing it directly in numbat/modules as Numbat code.

@hamirmahal hamirmahal requested review from sharkdp and triallax March 15, 2024 20:11
Copy link
Contributor

@triallax triallax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@hamirmahal
Copy link
Contributor Author

You're welcome!

@hamirmahal
Copy link
Contributor Author

I renamed it from solve_quadratic_equation to quadratic_equation because the solver doesn't show up as a suggestion when typing in quad otherwise.

image

@sharkdp
Copy link
Owner

sharkdp commented Mar 25, 2024

How about we move this to a module in extra:: and make it "opt in"? Something like extra::algebra. Then I'd be fine with merging it.

@hamirmahal
Copy link
Contributor Author

(signal: 11, SIGSEGV: invalid memory reference)

https://github.com/sharkdp/numbat/actions/runs/8424920106/job/23069903095?pr=398#step:8:267

I'm not too sure what caused that, or how to fix it.

When I try to reproduce the issue locally I get a different error.
hamir@hamir-desktop:~/numbat (feat/functionality-for-quadratic-equation)$ cargo build --locked --release --target=x86_64-apple-darwin
   Compiling libc v0.2.152
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.78
   Compiling generic-array v0.14.7
   Compiling typenum v1.17.0
   Compiling siphasher v0.3.11
   Compiling num-traits v0.2.17
   Compiling phf_shared v0.11.2
   Compiling rand_core v0.6.4
   Compiling regex-syntax v0.8.2
   Compiling rand v0.8.5
   Compiling quote v1.0.35
   Compiling cc v1.0.83
   Compiling syn v2.0.48
   Compiling bitflags v2.4.2
   Compiling tinyvec_macros v0.1.1
   Compiling getrandom v0.2.12
   Compiling rustix v0.38.30
   Compiling tinyvec v1.6.0
   Compiling errno v0.3.8
   Compiling phf_generator v0.11.2
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling spin v0.9.8
   Compiling untrusted v0.9.0
   Compiling regex-automata v0.4.4
   Compiling rustls-pki-types v1.1.0
   Compiling option-ext v0.2.0
   Compiling serde v1.0.195
   Compiling dirs-sys v0.4.1
   Compiling digest v0.10.7
   Compiling unicode-normalization v0.1.22
   Compiling ring v0.17.7
   Compiling phf_codegen v0.11.2
   Compiling phf v0.11.2
   Compiling num-integer v0.1.45
   Compiling cpufeatures v0.2.12
   Compiling log v0.4.20
   Compiling itoa v1.0.10
   Compiling unicode-bidi v0.3.15
   Compiling percent-encoding v2.3.1
   Compiling rustls v0.22.2
   Compiling utf8parse v0.2.1
   Compiling same-file v1.0.6
   Compiling sha2 v0.10.8
The following warnings were emitted during compilation:

warning: [email protected]: cc: error: unrecognized debug output level ‘full’
warning: [email protected]: cc: error: unrecognized command-line option ‘-arch’

error: failed to run custom build command for `ring v0.17.7`

Caused by:
  process didn't exit successfully: `/home/hamir/numbat/target/release/build/ring-393541a1edcf127a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_7_
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-apple-darwin")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-apple-darwin
  CC_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CC_x86_64_apple_darwin
  CC_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("cmpxchg16b,fxsr,sse,sse2,sse3,sse4.1,ssse3")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-apple-darwin
  CFLAGS_x86_64-apple-darwin = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_apple_darwin
  CFLAGS_x86_64_apple_darwin = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "include" "-I" "/home/hamir/numbat/target/x86_64-apple-darwin/release/build/ring-4e4393dd11ac0c15/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/home/hamir/numbat/target/x86_64-apple-darwin/release/build/ring-4e4393dd11ac0c15/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c"
  exit status: 1
  cargo:warning=cc: error: unrecognized debug output level ‘full’

  cargo:warning=cc: error: unrecognized command-line option ‘-arch’


  --- stderr


  error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "include" "-I" "/home/hamir/numbat/target/x86_64-apple-darwin/release/build/ring-4e4393dd11ac0c15/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/home/hamir/numbat/target/x86_64-apple-darwin/release/build/ring-4e4393dd11ac0c15/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args "cc" did not execute successfully (status code exit status: 1).

@@ -74,6 +74,7 @@ fn sech(x: Scalar) -> Scalar
fn asech(x: Scalar) -> Scalar
fn csch(x: Scalar) -> Scalar
fn acsch(x: Scalar) -> Scalar
fn quadratic_equation<A2, B2>(a: A2, b: B2, c: B2²/A2) -> String
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please move this to a new algebra section at the bottom of this page?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let me know if 5c7f33b isn't what you wanted.

section at the bottom of `list-functions.md`
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@sharkdp sharkdp merged commit a3d64f3 into sharkdp:master Mar 27, 2024
15 checks passed
@hamirmahal
Copy link
Contributor Author

You're welcome!

@hamirmahal hamirmahal deleted the feat/functionality-for-quadratic-equation branch March 27, 2024 07:17
@hamirmahal
Copy link
Contributor Author

Thank you for building this really awesome tool, and thank you for building it with Rust.

@sharkdp
Copy link
Owner

sharkdp commented Mar 27, 2024

Changes are live on numbat.dev

sharkdp added a commit that referenced this pull request Mar 27, 2024
@triallax
Copy link
Contributor

Thanks!

@hamirmahal
Copy link
Contributor Author

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add functionality to solve quadratic equation
3 participants