├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── custom.md
│ └── feature_request.md
└── workflows
│ ├── aws-s3-upload.yml
│ ├── nodejs.yml
│ ├── release-s3.yml
│ └── release.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── docker
├── Dockerfile
└── example_launch_linux.sh
├── docs
├── .gitignore
├── HedgehogScript
│ ├── array.md
│ ├── class.md
│ ├── control-flow.md
│ ├── function.md
│ ├── hedgehog-script.md
│ ├── hello-world.md
│ ├── string.md
│ └── variables.md
├── LICENSE
├── README.md
├── SUMMARY.md
├── book.json
├── contribute.md
├── overview.md
└── tutorials
│ ├── README.md
│ ├── basic-syntax.md
│ ├── data-preparation.md
│ ├── data-visualization.md
│ ├── gpu-acceleration.md
│ ├── markdown.md
│ ├── matrix-operations.md
│ ├── module-management.md
│ ├── share-code-via-url.md
│ ├── symbolic-computation.md
│ └── tex.md
├── hedgehog-docs
├── Hedgehog-Lab
│ ├── Advanced Topics
│ │ ├── Data Visualization.mdx
│ │ ├── GPU acceleration.mdx
│ │ ├── Markdown.mdx
│ │ ├── Symbolic Computation.mdx
│ │ ├── Table.mdx
│ │ └── TeX.mdx
│ ├── Browser Requirements.mdx
│ ├── Execution Results.mdx
│ ├── Features.mdx
│ ├── Programming Language.mdx
│ ├── Registering.mdx
│ ├── Resources.mdx
│ ├── The Environment.mdx
│ ├── intro-hedgehog-lab.md
│ └── package-management.mdx
├── Hedgehog-Script
│ ├── 1. intro-hedgehog-script.md
│ ├── 2. Expressions & Operators
│ │ ├── Expressions & Operators.md
│ │ ├── Null.mdx
│ │ ├── Regular Expression.mdx
│ │ ├── Variables.mdx
│ │ └── this.mdx
│ ├── 3. Statements and Declarations
│ │ ├── Conditional Statements.mdx
│ │ ├── Declarations.mdx
│ │ ├── Exception Handling.mdx
│ │ └── Loop Statements.mdx
│ ├── 4. Built-In Objects
│ │ ├── Array.mdx
│ │ ├── Basic Types.mdx
│ │ ├── Data Structures
│ │ │ ├── Data Structures.draft
│ │ │ └── Extra Useful Data Structures.draft
│ │ ├── JSON.mdx
│ │ ├── Maps.mdx
│ │ ├── Mat.mdx
│ │ ├── NaN.mdx
│ │ ├── Object.mdx
│ │ ├── Output.mdx
│ │ ├── Promises.draft
│ │ ├── Set.mdx
│ │ └── String.mdx
│ ├── 5. Matrix and Tensor
│ │ ├── Mat Object.mdx___
│ │ ├── Matrix.mdx
│ │ ├── Symbol.mdx_
│ │ └── Tensor.mdx
│ ├── 6. Functions
│ │ ├── Arguments Object.mdx
│ │ ├── Arrow Functions.mdx
│ │ ├── Functions.mdx
│ │ ├── HTTP requests and responses.draft
│ │ ├── Method definitions.mdx
│ │ └── Parameters.mdx
│ ├── 7. Classes
│ │ ├── Classes.mdx
│ │ ├── Constructors.mdx
│ │ ├── Private Class Features.md
│ │ ├── Public Class Fields.md
│ │ └── Static.draft
│ ├── 8. Errors
│ │ └── Errors.draft
│ └── 9. Reference
│ │ ├── Built-in Objects.draft
│ │ ├── OpsAndExpressions.draft
│ │ ├── Reference.draft
│ │ ├── SetExamples.draft
│ │ └── StringExamples.draft
├── Modules
│ └── Modules.md
├── Quickbook
│ └── intro-quickbook.md
├── README.md
├── babel.config.js
├── blog
│ ├── 2019-05-28-first-blog-post.md
│ ├── 2019-05-29-long-blog-post.md
│ ├── 2021-08-01-mdx-blog-post.mdx
│ ├── 2021-08-26-welcome
│ │ ├── docusaurus-plushie-banner.jpeg
│ │ └── index.md
│ └── authors.yml
├── contribution
│ ├── hedgehog-website.md
│ └── intro-contribution.md
├── developer
│ ├── hedgehog-canvas-components.md
│ ├── hedgehog-core-components.md
│ └── hedgehog-lab-components.md
├── docs
│ ├── intro.md
│ ├── tutorial-basics
│ │ ├── _category_.json
│ │ ├── congratulations.md
│ │ ├── create-a-blog-post.md
│ │ ├── create-a-document.md
│ │ ├── create-a-page.md
│ │ ├── deploy-your-site.md
│ │ └── markdown-features.mdx
│ └── tutorial-extras
│ │ ├── _category_.json
│ │ ├── img
│ │ ├── docsVersionDropdown.png
│ │ └── localeDropdown.png
│ │ ├── manage-docs-versions.md
│ │ └── translate-your-site.md
├── docusaurus.config.js
├── math
│ ├── Basic Operations
│ │ ├── Dot Divide.draft
│ │ ├── Dot Multiply.draft
│ │ ├── bounds.mdx
│ │ ├── ceil.draft
│ │ ├── check_input.draft
│ │ ├── factorial.mdx
│ │ ├── floor.mdx
│ │ ├── gcd.mdx
│ │ └── sum.mdx
│ ├── Data
│ │ ├── any_missing.mdx
│ │ ├── fill_missing.mdx
│ │ ├── is_local_max.mdx
│ │ ├── is_local_min.mdx
│ │ ├── is_missing.mdx
│ │ ├── missing.mdx
│ │ ├── normalize.mdx
│ │ ├── rm_missing.mdx
│ │ └── smooth.mdx
│ ├── Decompositions
│ │ ├── QR.mdx
│ │ ├── cholesky.mdx
│ │ └── lup.mdx
│ ├── Linear Equation Systems
│ │ ├── lsolve.mdx
│ │ ├── lusolve.mdx
│ │ └── usolve.mdx
│ ├── Misc
│ │ ├── all.mdx
│ │ ├── deep_copy.mdx
│ │ └── test.mdx
│ ├── Probability and Statistics
│ │ ├── Quantiles.mdx
│ │ ├── correcoef.mdx
│ │ ├── cov.mdx
│ │ ├── iqr.mdx
│ │ ├── max.mdx
│ │ ├── mean.mdx
│ │ ├── median.mdx
│ │ ├── min.mdx
│ │ ├── mink.mdx
│ │ ├── multinomial.mdx
│ │ ├── percentile.mdx
│ │ └── rms.mdx
│ ├── Properties
│ │ ├── det.mdx
│ │ ├── is_diag.mdx
│ │ ├── is_number.mdx
│ │ ├── is_symmetric.mdx
│ │ ├── is_tril.mdx
│ │ ├── is_triu.mdx
│ │ ├── ndim.mdx
│ │ ├── shape.mdx
│ │ └── trace.mdx
│ ├── Transformations and creations
│ │ ├── flatten.mdx
│ │ ├── hankel.mdx
│ │ ├── identity.mdx
│ │ ├── inv.mdx
│ │ ├── magic.mdx
│ │ ├── pascal.mdx
│ │ ├── reshape.mdx
│ │ ├── resize.mdx
│ │ ├── toeplitz.draft
│ │ ├── transpose.mdx
│ │ └── vander.mdx
│ └── intro-math.md
├── package-lock.json
├── package.json
├── sidebars.js
├── src
│ ├── components
│ │ └── HomepageFeatures
│ │ │ ├── index.js
│ │ │ └── styles.module.css
│ ├── css
│ │ └── custom.css
│ └── pages
│ │ ├── index.js
│ │ ├── index.module.css
│ │ └── markdown-page.md
├── static
│ ├── .nojekyll
│ └── img
│ │ ├── browser_requirements_webgl.jpg
│ │ ├── community.png
│ │ ├── docusaurus.png
│ │ ├── environment.png
│ │ ├── execresults.png
│ │ ├── execresults2.png
│ │ ├── favicon.ico
│ │ ├── features.png
│ │ ├── githubIcon.png
│ │ ├── githubIcon_32x32.png
│ │ ├── googleIcon.png
│ │ ├── googleIcon_32x32.png
│ │ ├── hedgehog_1f994 copy.png
│ │ ├── hedgehog_1f994.ico
│ │ ├── hedgehog_1f994.png
│ │ ├── linkedinIcon.png
│ │ ├── linkedinIcon_16x16.png
│ │ ├── linkedinIcon_32x32.png
│ │ ├── logo.svg
│ │ ├── profilearea.png
│ │ ├── promises.png
│ │ ├── register3.png
│ │ ├── registerHHL.png
│ │ ├── resources.png
│ │ ├── timeline2.png
│ │ ├── undraw_docusaurus_mountain.svg
│ │ ├── undraw_docusaurus_react.svg
│ │ ├── undraw_docusaurus_tree.svg
│ │ ├── yourscript3.png
│ │ ├── yourscripts.png
│ │ └── yourscripts2.png
└── yarn.lock
├── hedgehog-libs
├── README.md
└── math
│ ├── LICENSE
│ ├── QR.hhs
│ ├── QR_test.hhs
│ ├── README.md
│ ├── all.hhs
│ ├── any_missing.hhs
│ ├── any_missing_test.hhs
│ ├── bounds.hhs
│ ├── bounds_test.hhs
│ ├── ceil.hhs
│ ├── ceil_test.hhs
│ ├── check_input.hhs
│ ├── check_input_test.hhs
│ ├── cholesky.hhs
│ ├── cholesky_test.hhs
│ ├── correcoef.hhs
│ ├── correcoef_test.hhs
│ ├── cov.hhs
│ ├── cov_test.hhs
│ ├── cubic_equation.hhs
│ ├── cubic_equation_test
│ ├── deep_copy.hhs
│ ├── det.hhs
│ ├── det_test.hhs
│ ├── dot_divide.hhs
│ ├── dot_divide_test.hhs
│ ├── dot_multiply.hhs
│ ├── dot_multiply_test.hhs
│ ├── factorial.hhs
│ ├── factorial_test.hhs
│ ├── fillmissing.hhs
│ ├── fillmissing_test.hhs
│ ├── flatten.hhs
│ ├── floor.hhs
│ ├── floor_test.hhs
│ ├── gcd.hhs
│ ├── gcd_test.hhs
│ ├── hankel.hhs
│ ├── hankel_test.hhs
│ ├── hedgehog-package.json
│ ├── identity.hhs
│ ├── identity_test.hhs
│ ├── inv.hhs
│ ├── iqr.hhs
│ ├── iqr_test.hhs
│ ├── is_diag.hhs
│ ├── is_diag_test.hhs
│ ├── is_local_max.hhs
│ ├── is_local_max_test.hhs
│ ├── is_local_min.hhs
│ ├── is_local_min_test.hhs
│ ├── is_missing.hhs
│ ├── is_missing_test.hhs
│ ├── is_number.hhs
│ ├── is_symmetric.hhs
│ ├── is_symmetric_test.hhs
│ ├── is_tril.hhs
│ ├── is_tril_test.hhs
│ ├── is_triu.hhs
│ ├── is_triu_test.hhs
│ ├── lsolve.hhs
│ ├── lsolve_test.hhs
│ ├── lu.hhs
│ ├── lu_test.hhs
│ ├── lusolve.hhs
│ ├── lusolve_test.hhs
│ ├── magic.hhs
│ ├── magic_test.hhs
│ ├── max.hhs
│ ├── mean.hhs
│ ├── mean_test.hhs
│ ├── median.hhs
│ ├── median_test.hhs
│ ├── min.hhs
│ ├── mink.hhs
│ ├── mink_test.hhs
│ ├── missing.hhs
│ ├── missing_test.hhs
│ ├── multinomial.hhs
│ ├── multinomial_test.hhs
│ ├── ndim.hhs
│ ├── ndim_test.hhs
│ ├── normalize.hhs
│ ├── normalize_test.hhs
│ ├── package-lock.json
│ ├── pascal.hhs
│ ├── pascal_test.hhs
│ ├── percentile.hhs
│ ├── percentile_test.hhs
│ ├── quadratic_equation.hhs
│ ├── quadratic_equation_test.hhs
│ ├── quantile.hhs
│ ├── quantile_test.hhs
│ ├── quartic_equation.hhs
│ ├── quartic_equation_test.hhs
│ ├── reshape.hhs
│ ├── reshape_test.hhs
│ ├── resize.hhs
│ ├── resize_test.hhs
│ ├── rmmissing.hhs
│ ├── rmmissing_test.hhs
│ ├── rms.hhs
│ ├── rms_test.hhs
│ ├── shape.hhs
│ ├── smooth.hhs
│ ├── smooth_test.hhs
│ ├── standard_missing.hhs
│ ├── standard_missing_test.hhs
│ ├── sum.hhs
│ ├── test.hhs
│ ├── toeplitz.hhs
│ ├── trace.hhs
│ ├── trace_test.hhs
│ ├── transpose.hhs
│ ├── transpose_test.hhs
│ ├── usolve.hhs
│ ├── usolve_test.hhs
│ ├── vander.hhs
│ └── vander_test.hhs
├── hedgehog-package-manager
├── LICENSE
├── README.md
└── hedgehog-packages.json
├── lerna.json
├── package.json
├── packages
├── hedgehog-canvas
│ ├── .gitignore
│ ├── README.md
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ ├── src
│ │ ├── App.css
│ │ ├── App.test.tsx
│ │ ├── App.tsx
│ │ ├── Output
│ │ │ ├── Output.tsx
│ │ │ └── index.ts
│ │ ├── index.css
│ │ ├── index.tsx
│ │ ├── logo.svg
│ │ ├── react-app-env.d.ts
│ │ ├── reportWebVitals.ts
│ │ └── setupTests.ts
│ └── tsconfig.json
├── hedgehog-core
│ ├── .eslintrc
│ ├── package-lock.json
│ ├── package.json
│ ├── readme.md
│ ├── src
│ │ ├── index.ts
│ │ ├── lib
│ │ │ ├── mathlib.ts
│ │ │ ├── matrix.ts
│ │ │ ├── symbolic.ts
│ │ │ ├── table.ts
│ │ │ └── tensor.ts
│ │ ├── output
│ │ │ └── output-item.ts
│ │ ├── runtime
│ │ │ ├── globalConfigVars.ts
│ │ │ ├── index.ts
│ │ │ ├── prelude.ts
│ │ │ └── vars.ts
│ │ ├── transpiler
│ │ │ ├── CodeSnippetObject.ts
│ │ │ ├── FetchURL
│ │ │ │ ├── fetchApi.ts
│ │ │ │ └── fetchURL.ts
│ │ │ ├── GithubDependency
│ │ │ │ └── githubDependency.ts
│ │ │ ├── operator-overload.ts
│ │ │ ├── preprocessor.ts
│ │ │ ├── splitSourceCodeIntoJSandHHSSnippetList.ts
│ │ │ └── transpiler-core.ts
│ │ └── utilites
│ │ │ ├── fetch-library.ts
│ │ │ └── process-raw-inputs.ts
│ ├── test
│ │ ├── basicTest
│ │ │ └── test.ts
│ │ ├── js-embedded-test
│ │ │ ├── complexTest.ts
│ │ │ └── simpleTest.ts
│ │ ├── matrixTest
│ │ │ └── matrixOperatorTest.ts
│ │ └── test.ts
│ ├── tsconfig.json
│ └── webpack.config.js
├── hedgehog-lab
│ ├── .eslintrc
│ ├── .gitignore
│ ├── config-overrides.js
│ ├── package.json
│ ├── public
│ │ ├── cat.png
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ ├── readme.md
│ ├── src
│ │ ├── App.css
│ │ ├── App.tsx
│ │ ├── HedgehogLab.tsx
│ │ ├── index.css
│ │ ├── index.tsx
│ │ └── react-app-env.d.ts
│ └── tsconfig.json
└── hedgehog-website
│ ├── .eslintrc
│ ├── .gitignore
│ ├── config-overrides.js
│ ├── package.json
│ ├── public
│ ├── cat.png
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ ├── src
│ ├── App.css
│ ├── App.tsx
│ ├── compiler.ts
│ ├── compiler.worker.ts
│ ├── components
│ │ ├── Auth
│ │ │ ├── Account
│ │ │ │ └── AccountMenu.tsx
│ │ │ ├── Action
│ │ │ │ └── AuthAction.tsx
│ │ │ └── Dialog
│ │ │ │ └── AuthDialog.tsx
│ │ ├── Base
│ │ │ ├── Editor
│ │ │ │ ├── Editor.tsx
│ │ │ │ └── Loading.tsx
│ │ │ ├── Input
│ │ │ │ ├── BaseOutlinedInput
│ │ │ │ │ └── BaseOutlinedInput.tsx
│ │ │ │ ├── Copy
│ │ │ │ │ └── CopyInput.tsx
│ │ │ │ ├── Description
│ │ │ │ │ └── UserDescriptionInput.tsx
│ │ │ │ ├── Email
│ │ │ │ │ └── EmailInput.tsx
│ │ │ │ ├── Password
│ │ │ │ │ └── PasswordInput.tsx
│ │ │ │ ├── Snippet
│ │ │ │ │ ├── Description
│ │ │ │ │ │ └── SnippetDescriptionInput.tsx
│ │ │ │ │ └── Name
│ │ │ │ │ │ └── SnippetNameInput.tsx
│ │ │ │ └── UserName
│ │ │ │ │ └── UserNameInput.tsx
│ │ │ ├── Popup
│ │ │ │ ├── BasePopupButton.tsx
│ │ │ │ └── BasePopupText.tsx
│ │ │ └── Theme
│ │ │ │ └── SwitchThemeButton.tsx
│ │ ├── Layout
│ │ │ ├── ContainerLayout.tsx
│ │ │ ├── Layout.tsx
│ │ │ ├── ResizableColumn
│ │ │ │ └── ResizableColumn.tsx
│ │ │ ├── SideBar
│ │ │ │ ├── SideBar.tsx
│ │ │ │ ├── _sideList.tsx
│ │ │ │ └── _sideListItem.tsx
│ │ │ ├── SnippetsLayout
│ │ │ │ └── SnippetsLayout.tsx
│ │ │ └── TopBar
│ │ │ │ ├── DevModeAlert.tsx
│ │ │ │ ├── RightButton.tsx
│ │ │ │ ├── TopBar.tsx
│ │ │ │ ├── _communityButtons.tsx
│ │ │ │ ├── _compilerButton.tsx
│ │ │ │ ├── _fullScreenButton.tsx
│ │ │ │ └── _gitHubButton.tsx
│ │ ├── Meta
│ │ │ ├── Meta.tsx
│ │ │ └── types.ts
│ │ ├── Results
│ │ │ ├── OutputItemCompoments
│ │ │ │ └── TableComponent.tsx
│ │ │ └── Results.tsx
│ │ ├── Share
│ │ │ ├── ShareDialog.tsx
│ │ │ └── SharePopup.tsx
│ │ ├── Snippet
│ │ │ ├── CreateSnippetDialog.tsx
│ │ │ ├── Delete
│ │ │ │ ├── DeleteAlert.tsx
│ │ │ │ └── DeletePopup.tsx
│ │ │ ├── List
│ │ │ │ └── SnippetList.tsx
│ │ │ ├── Rename
│ │ │ │ └── RenameDialog.tsx
│ │ │ ├── Save
│ │ │ │ ├── SaveDialog.tsx
│ │ │ │ └── SaveState.tsx
│ │ │ ├── Search
│ │ │ │ └── SearchSnippet.tsx
│ │ │ ├── Snippet.tsx
│ │ │ └── UpdatedSnippet.tsx
│ │ ├── YourCode
│ │ │ ├── Config
│ │ │ │ └── SideBar.ts
│ │ │ ├── Header
│ │ │ │ └── YourCodeHeader.tsx
│ │ │ └── YourCode.tsx
│ │ └── styled.ts
│ ├── config.tsx
│ ├── hooks
│ │ ├── useApp.tsx
│ │ ├── useAuth.tsx
│ │ ├── useCompilier.ts
│ │ ├── useCurrentRoute.ts
│ │ ├── useEditor.ts
│ │ ├── useEditorMeta.ts
│ │ ├── useSnippet.ts
│ │ └── useSystemTheme.ts
│ ├── index.css
│ ├── index.tsx
│ ├── interfaces
│ │ ├── IFormInput.ts
│ │ └── ISnippetName.ts
│ ├── logo.svg
│ ├── models
│ │ ├── account
│ │ │ └── accountModal.ts
│ │ ├── forget
│ │ │ └── forgetModal.ts
│ │ ├── login
│ │ │ └── loginModal.ts
│ │ ├── sign
│ │ │ └── signModel.ts
│ │ └── snippet
│ │ │ └── renameModal.ts
│ ├── network
│ │ ├── fetcher.ts
│ │ └── http.ts
│ ├── output.worker.ts
│ ├── pages
│ │ ├── Auth
│ │ │ ├── Auth.tsx
│ │ │ ├── Forget.tsx
│ │ │ ├── Login.tsx
│ │ │ └── Sign.tsx
│ │ ├── Draft
│ │ │ └── Draft.tsx
│ │ ├── Email
│ │ │ └── EmailVerification.tsx
│ │ ├── Example
│ │ │ └── Example.tsx
│ │ ├── Explore
│ │ │ └── Explore.tsx
│ │ ├── Home
│ │ │ ├── Home.tsx
│ │ │ ├── _community.tsx
│ │ │ ├── _draft.tsx
│ │ │ ├── _gettingStarted.tsx
│ │ │ ├── _gridItem.tsx
│ │ │ └── _title.tsx
│ │ ├── Settings
│ │ │ └── Account.tsx
│ │ ├── Snippets
│ │ │ ├── Editor.tsx
│ │ │ └── Snippets.tsx
│ │ └── Timeline
│ │ │ └── Timeline.tsx
│ ├── react-app-env.d.ts
│ ├── route
│ │ └── route.tsx
│ ├── service-worker.ts
│ ├── serviceWorkerRegistration.ts
│ ├── states
│ │ ├── RCompilerStates.ts
│ │ ├── RLayoutStates.ts
│ │ ├── RSnippetStates.ts
│ │ ├── RUserStates.ts
│ │ └── RYourCodeStates.ts
│ ├── themes
│ │ ├── RThemeStates.ts
│ │ ├── labTheme.ts
│ │ ├── monacoTheme.ts
│ │ └── theme.tsx
│ ├── tutorials.ts
│ └── utils
│ │ ├── deepmerge.ts
│ │ ├── ga4.js
│ │ ├── kFormatter.ts
│ │ └── toCapitalize.ts
│ └── tsconfig.json
├── patches
└── gpu.js+2.11.4.patch
├── scripts
└── publish-to-github.sh
├── tsconfig.json
├── vercel.json
└── yarn.lock
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/custom.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Custom issue template
3 | about: Describe this issue template's purpose here.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/workflows/nodejs.yml:
--------------------------------------------------------------------------------
1 | name: CI runner
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v1
10 |
11 | - name: Use Node.js 16.x
12 | uses: actions/setup-node@v1
13 | with:
14 | node-version: '16.x'
15 |
16 | - name: Install Dependencies
17 | run: |
18 | yarn
19 |
20 | - name: Build
21 | run: yarn build
22 | env:
23 | CI: true
24 |
--------------------------------------------------------------------------------
/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian:11
2 |
3 | # prepare the system and dependencies
4 | RUN apt-get update && \
5 | apt-get upgrade -y && \
6 | apt-get install -y yarnpkg git python3 pkg-config npm && \
7 | apt-get autoremove && \
8 | apt-get autoclean && \
9 | apt-get clean && \
10 | rm -rf /var/lib/apt/lists/*
11 |
12 | # add user
13 | RUN useradd -m usr && echo "usr:usr" | chpasswd
14 |
15 | # prepare the repo and build
16 | RUN cd /home/usr && \
17 | runuser -u usr -- git clone https://github.com/Hedgehog-Computing/hedgehog-lab.git
18 | RUN cd /home/usr/hedgehog-lab && runuser -u usr -- sh -c "git checkout dev && /usr/share/nodejs/yarn/bin/yarn install && /usr/share/nodejs/yarn/bin/yarn build"
19 |
20 | # create the starter
21 | RUN echo "#!/bin/sh" > /opt/run.sh && \
22 | echo "cd /home/usr/hedgehog-lab && /usr/share/nodejs/yarn/bin/yarn watch" >> /opt/run.sh && \
23 | chmod +x /opt/run.sh
24 |
25 | ENTRYPOINT ["/bin/sh"]
26 | CMD ["/opt/run.sh"]
27 | USER usr
28 |
29 |
--------------------------------------------------------------------------------
/docker/example_launch_linux.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | docker run -p 3000:3000 hedgehog-lab
4 |
5 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | # Node rules:
2 | ## Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
3 | .grunt
4 |
5 | ## Dependency directory
6 | ## Commenting this out is preferred by some people, see
7 | ## https://docs.npmjs.com/misc/faq#should-i-check-my-node_modules-folder-into-git
8 | node_modules
9 |
10 | # Book build output
11 | _book
12 |
13 | # eBook build output
14 | *.epub
15 | *.mobi
16 | *.pdf
--------------------------------------------------------------------------------
/docs/HedgehogScript/class.md:
--------------------------------------------------------------------------------
1 | # Class
--------------------------------------------------------------------------------
/docs/HedgehogScript/function.md:
--------------------------------------------------------------------------------
1 | # Function
--------------------------------------------------------------------------------
/docs/HedgehogScript/hello-world.md:
--------------------------------------------------------------------------------
1 | # Hello World
2 |
3 | Use `print()` function to print `"hello world"` string in Hedgehog Lab:
4 |
5 |
6 |
7 | Do you see the output `hello world` on the right? Congratulations! Your first Hedgehog Script runs successfully!
8 |
--------------------------------------------------------------------------------
/docs/HedgehogScript/string.md:
--------------------------------------------------------------------------------
1 | # String
2 |
3 | All properties and features from ```String``` object in JavaScript are available at Hedgehog Script.
4 |
5 |
--------------------------------------------------------------------------------
/docs/HedgehogScript/variables.md:
--------------------------------------------------------------------------------
1 | # Variables
2 |
3 | You can define variable and constant in this way:
4 |
5 | - Use keyword `let` for a variable, for example, `let x = 10`;
6 | - Define a variable without a keyword, for example, `x = 10`;
7 | - Use keyword `const` for a constant, for example, `const x = 10`.
8 |
9 |
--------------------------------------------------------------------------------
/docs/SUMMARY.md:
--------------------------------------------------------------------------------
1 | # Table of contents
2 |
3 | * [About Hedgehog Book](README.md)
4 | * [A Quick Overview](overview.md)
5 | * [Hedgehog Script](HedgehogScript/hedgehog-script.md)
6 | * [Hello World](HedgehogScript/hello-world.md)
7 | * [Variables](HedgehogScript/variables.md)
8 | * [String](HedgehogScript/string.md)
9 | * [Array](HedgehogScript/array.md)
10 | * [Control Flow](HedgehogScript/control-flow.md)
11 | * [Functiobn](HedgehogScript/function.md)
12 | * [Class](HedgehogScript/class.md)
13 | * [Tutorials](tutorials/README.md)
14 | * [Basic Syntax](tutorials/basic-syntax.md)
15 | * [Matrix operations](tutorials/matrix-operations.md)
16 | * [Data preparation](tutorials/data-preparation.md)
17 | * [Data Visualization](tutorials/data-visualization.md)
18 | * [Symbolic Computation](tutorials/symbolic-computation.md)
19 | * [Markdown](tutorials/markdown.md)
20 | * [TeX](tutorials/tex.md)
21 | * [Module Management](tutorials/module-management.md)
22 | * [GPU Acceleration](tutorials/gpu-acceleration.md)
23 | * [Share code via URL](tutorials/share-code-via-url.md)
24 | * [Contribute to this book](contribute.md)
25 |
26 |
--------------------------------------------------------------------------------
/docs/book.json:
--------------------------------------------------------------------------------
1 | { "title": "Hedgehog Book",
2 | "plugins": ["responsive-iframes", "wide-page", "katex"] ,
3 | "pluginsConfig": {
4 | "fontsettings": {
5 | "theme": "white",
6 | "family": "sans",
7 | "size": 2
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/docs/overview.md:
--------------------------------------------------------------------------------
1 | # A Quick Overview of Hedgehog Script and Hedgehog Lab
2 |
3 | Hedgehog Script supports most features and syntax from JavaScript, which is also quite similar as Java, C and C++. Each statement can be seperated with new-line with or without semicolons(;), for example:
4 |
5 |
6 |
7 | Hedgehog Script support types, objects and
--------------------------------------------------------------------------------
/docs/tutorials/README.md:
--------------------------------------------------------------------------------
1 | # Tutorials
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/basic-syntax.md:
--------------------------------------------------------------------------------
1 | # Basic Syntax
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/data-preparation.md:
--------------------------------------------------------------------------------
1 | # Data preparation
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/data-visualization.md:
--------------------------------------------------------------------------------
1 | # Data Visualization
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/gpu-acceleration.md:
--------------------------------------------------------------------------------
1 | # GPU Acceleration
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/markdown.md:
--------------------------------------------------------------------------------
1 | # Markdown
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/module-management.md:
--------------------------------------------------------------------------------
1 | # Module Management
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/share-code-via-url.md:
--------------------------------------------------------------------------------
1 | # Share code via URL
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/symbolic-computation.md:
--------------------------------------------------------------------------------
1 | # Symbolic Computation
2 |
3 |
--------------------------------------------------------------------------------
/docs/tutorials/tex.md:
--------------------------------------------------------------------------------
1 | # TeX
2 |
3 |
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Advanced Topics/Data Visualization.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # Data Visualization
6 |
7 | 1. **PlotlyJS** and **E-Charts** are used to implement data visualization.
8 |
9 | 2. We have some built-in functions for making and viewing figures:
10 |
11 | - `plot2D(setX, setY)` - A scatter plot
12 |
13 | - `plot2DLine(setX, setY )` - A line
14 |
15 | - `plot3D(setX, setY, setZ)` - A 3-D scatter plot
16 |
17 | - `plot3DMesh(setX, setY, setZ)` - A 3-D mesh
18 |
19 | Here is an example:
20 |
21 |
24 |
25 | ---
26 |
27 | :::tip
28 |
29 | For more ways to view data, visit [PlotlyJS](https://plotly.com/javascript/)
30 |
31 | Then use our built-in function `draw(data, layout)` in conjunction with PlotlyJS
32 |
33 | :::
34 |
35 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Advanced Topics/GPU acceleration.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 | # GPU Acceleration
8 |
9 | 1. Hedgehog Lab supports **GPU acceleration** for computations done inside the browser.
10 |
11 | 2. GPU Acceleration utilizes the power of your graphics card(s) to increase performance.
12 |
13 | 3. It can take significantly less time for some matrix calculations among other things.
14 |
15 | 4. To use it, set a `variable`'s `mode` property to 'gpu'.
16 |
17 | Here is an example:
18 |
19 |
22 |
23 | ---
24 |
25 | :::tip
26 |
27 | Try out different dimensions or different calculations to see the impact.
28 |
29 | The results may vary among different browsers and computers.
30 |
31 | :::
32 |
33 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Advanced Topics/Markdown.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Markdown
6 |
7 | In Hedgehog Lab you can encapsulate output in markdown.
8 |
9 | This is done by calling the markdown function:
10 |
11 | ```js
12 | markdown(' Your markdown here ')
13 | ```
14 |
15 | For multiple lines, use **template strings** instead:
16 |
17 | ```js
18 | markdown(`
19 | # Your markdown title1
20 |
21 | ## Your markdown title2
22 |
23 | Your markdown context
24 | `)
25 | ```
26 | //change this example to h1 h2 h3 plaintext codeexmaple bold inline code block url (~10 lines of code)
27 | Here is an example:
28 |
29 |
32 |
33 | ---
34 |
35 | :::tip
36 |
37 | To learn **markdown** one can use Google for a variety of many resources.
38 |
39 | :::
40 |
41 | ---
42 |
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Advanced Topics/Symbolic Computation.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 5
3 | ---
4 |
5 | # Symbolic Computation
6 |
7 | **Symbols** can be used along with **TeX** for writing formulas and calculating them.
8 |
9 | The first step is to declare a `variable` as a `Symbol`:
10 |
11 | ```js
12 | let x = sym('x')
13 | ```
14 |
15 | Then write an expression using that symbol:
16 |
17 | ```js
18 | let fx = (x^3) + sin(x)
19 | ```
20 |
21 | You can output the formula:
22 | ```js
23 | formulaTex `f(x)= ${fx}`
24 | ```
25 |
26 | Here is an example of performing calculations on the formula:
27 |
28 | - Finding a derivative:
29 | ```js
30 | formulaTex`f'(x) = ${diff(fx, x)}`
31 | ```
32 |
33 | - Calculating an integral:
34 | ```js
35 | formulaTex`\int{f(x)dx} = ${integrate(fx, x)}`
36 | ```
37 |
38 |
39 |
40 | Here's an example with several types of calculations:
41 |
42 |
43 |
46 |
47 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Advanced Topics/Table.mdx:
--------------------------------------------------------------------------------
1 | # Table
2 |
3 | 1. Tables can be used to neatly display data in a row-column manner
4 |
5 | 2. Hedgehog Script has some built-in functions for making and showing Tables:
6 |
7 | - `new Table()` is the constructor, typically you'd enter raw cvs
8 | - `showTable()` is the analogue to `print()`, it will display the table
9 |
10 |
11 | **To build a table follow these steps:**
12 |
13 | - Create a csv string yourself or import one
14 |
15 | - Feed the csv string into the table constructor
16 |
17 | - Use `showTable()` to output it
18 |
19 |
20 |
21 | Here is an example:
22 |
23 |
26 |
27 | ---
28 |
29 | :::tip
30 |
31 | A way to check your csv string is by calling `csv2mat()`
32 |
33 | It will print what the table will look like in a Matrix.
34 |
35 | :::
36 |
37 | ---
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Advanced Topics/TeX.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 4
3 | ---
4 |
5 | # TeX
6 |
7 | Hedgehog Lab can have output displayed as **TeX**
8 |
9 | To write something in **TeX**, call `tex()` and input the **TeX** as a parameter:
10 |
11 | ``` tex("\\text{Welcome to Hedgehog Lab.}") ```
12 |
13 | - `\\text` is used to create a string
14 |
15 | - Your actual text will be in the `{}` space
16 |
17 | - Everything is encapsulated by double quotations (`" "`)
18 |
19 | This is how to write a **formula** in TeX:
20 |
21 | - `formulaTex("Y = mx + b")`
22 |
23 | To convert a `variable` to TeX just call the `toTex()` method:
24 |
25 | - `A.toTex()`
26 |
27 |
30 |
31 | ---
32 |
33 | :::tip
34 |
35 | Information regarding TeX is widely documented on the Internet.
36 |
37 | :::
38 |
39 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Execution Results.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 6
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 |
8 | # Execution Results
9 |
10 |
11 | 1. The **execution results** are located on the right-hand side window (the right window)
12 |
13 | 2. The results can be display by clicking the **run** button at the top right
14 |
15 | 3. The results will be displayed *continuously* if **LiveMode** is turned on
16 |
17 | ---
18 |
19 | 
20 |
21 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Features.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 | # Features
8 |
9 | 1. Create, modify, delete, manage and execute your script
10 |
11 | 
12 |
13 | ---
14 |
15 | 2. Explore and follow others' scripts
16 |
17 | 
18 |
19 | ---
20 |
21 | 3. Explore all scripts in the community
22 |
23 | 
24 |
25 | ---
26 |
27 |
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Programming Language.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 5
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 |
8 | # The Programming Language
9 |
10 | 1. The programming language used in Hedgehog Lab is **Hedgehog Script**
11 |
12 | 2. **Hedgehog Script** is a high level dynamic programming langauage compatible with and built on **JavaScript/TypeScript**
13 |
14 | 3. It compiles and executed inside your browser
15 |
16 | 4. It is **multi-paradigm**
17 | - Functional Programming (FP)
18 | - Object-Oriented Programming (OOP)
19 | - Dynamic types
20 | - Metaprogramming
21 |
22 | 5. Sweet syntax for **Matrix** and **Tensor** operations
23 |
24 | 6. Easy to import packages/modules using `*import`
25 |
26 | :::info
27 |
28 | Our book on Hedgehog Script can be found via: [Hedgehog Script](../Hedgehog-Script/intro-hedgehog-script)
29 |
30 | :::
31 |
32 |
33 |
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Registering.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 | # Registering
8 |
9 | 1. Registration is not required.
10 |
11 | 
12 |
13 | ---
14 |
15 |
16 | 2. Registration and login is necessary for storing scripts and data.
17 |
18 |
19 |
20 | 
21 |
22 |
23 |
24 | ---
25 |
26 | :::tip
27 |
28 | ---
29 |
30 | Regarding registration:
31 |
32 | - Email is required
33 | - Username is required and will not be changed
34 | - One's username will be their unique id for sharing scripts/packages:
35 |
36 | - **[https://hlab.app/s/YOUR_USERNAME_HERE/YOUR_CODE]**
37 |
38 | - **[`*import @username/package`]**
39 |
40 | :::
41 |
42 | ---
43 |
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/Resources.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 7
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 | # Resources
8 |
9 | 1. The link to this book, **Hedgehog Book** is located via the top right button **"Book"**
10 |
11 | 2. Next to it is our official community **Discord** link
12 |
13 | 3. Lastly, is our official **Github** page
14 |
15 | 
16 |
17 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/The Environment.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 4
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 | # The Environment
8 |
9 | 1. The **left-side bar** manages login information along with all your code snippets
10 |
11 | 2. The **codepad** (left-hand side window) is your input for source code
12 |
13 | 3. The **output** is on the right and it contains all execution results
14 |
15 | 4. The **run** button causes code to execute (if not in **LiveMode**)
16 |
17 | 5. The **LiveMode** switch is at the center top and when on, executes continuously.
18 |
19 | ---
20 |
21 | 
22 |
23 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Lab/package-management.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Pacakge Management
6 |
7 | There are five ways to manage packages in the Hedgehog Lab:
8 |
9 | ### 1. Import registered packages `*import package: function`
10 |
11 | Since
12 |
13 | ### 2. Import a function from URL `*import your_url`.
14 |
15 | ### 3. Import a function as `*import @username/filename`
16 |
17 | ### 4. Import a function hosted on GitHub
18 |
19 | `*github username/repo/branch/filepath`
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Script/4. Built-In Objects/Output.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 |
8 | # Output
9 |
10 | Output is crucial to any programming language. They define how a user can access information.
11 |
12 | There's two key ways to do so that we'll briefly go over:
13 |
14 | - `console.log()`: logs to the web browser console
15 |
16 | - `print()`: prints directly in the Hedgehog Lab environment
17 | :::tip
18 | In Chrome use 'F12' to open the console. Other browsers may vary slightly.
19 | :::
20 |
21 | Let's go over an example using both:
22 |
23 |
27 |
28 | :::tip
29 |
30 | Use `print()` for users and `console.log()` for yourself
31 |
32 | :::
33 |
34 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Script/5. Matrix and Tensor/Mat Object.mdx___:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Script/5. Matrix and Tensor/Symbol.mdx_:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Symbol
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Script/6. Functions/Method definitions.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 |
8 | # Method Definitions
9 |
10 | Method definitions have a shorter syntax for defining a function method.
11 |
12 | Here is an example of the syntax, given normal code:
13 |
14 |
18 |
19 |
20 | :::tip
21 |
22 | Create methods by doing this:
23 |
24 | - Write the name of the method follow by parameters if any, then a curly bracket which wraps the method's body!
25 |
26 | :::
27 |
28 |
29 | Overall, there's not much more to method definitions and we've learned the standard way.
30 |
31 | However, the more flexibility the better!
32 |
33 | ---
34 |
35 |
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Script/7. Classes/Constructors.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
6 |
7 |
8 | # Constructors
9 |
10 | The `constructor` method is a special, unique method of a `class` to initialize an instance of that class.
11 |
12 | A simple example is the following:
13 |
14 |
18 |
19 | :::note
20 | `constructor()` can have an arbitrary amount of parameters, including none.
21 | :::
22 |
23 | A `constructor` is powerful in the sense that it can manage all the initialization of an object, executing before anything else.
24 |
25 | :::tip
26 | You don't **need** to write a `constructor`!
27 |
28 | - A virtual, empty one will be inserted by default.
29 |
30 | - Similarly if you forget to call `super()` in a subclass, Hedgehog Script will call it for you.
31 | :::
32 |
33 | ---
34 |
35 |
36 |
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Script/9. Reference/Reference.draft:
--------------------------------------------------------------------------------
1 | # Reference
2 |
3 | Under construction
--------------------------------------------------------------------------------
/hedgehog-docs/Hedgehog-Script/9. Reference/StringExamples.draft:
--------------------------------------------------------------------------------
1 | string example methods with subchapters
--------------------------------------------------------------------------------
/hedgehog-docs/README.md:
--------------------------------------------------------------------------------
1 | # Hedgehog Book
2 |
3 | This is the official document for Hedgehog Lab built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
4 |
5 | You can read the latest release version at [https://hedgehog-computing.github.io](https://hedgehog-computing.github.io).
6 |
7 | ### Installation
8 |
9 | ```
10 | $ yarn
11 | ```
12 |
13 | ### Local Development
14 |
15 | ```
16 | $ yarn start
17 | ```
18 |
19 | This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
20 |
21 | ### Build
22 |
23 | ```
24 | $ yarn build
25 | ```
26 |
27 | This command generates static content into the `build` directory and can be served using any static contents hosting service.
28 |
29 | ### Deployment
30 |
31 | Using SSH:
32 |
33 | ```
34 | $ USE_SSH=true yarn deploy
35 | ```
36 |
37 | Not using SSH:
38 |
39 | ```
40 | $ GIT_USER= yarn deploy
41 | ```
42 |
43 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
44 |
--------------------------------------------------------------------------------
/hedgehog-docs/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3 | };
4 |
--------------------------------------------------------------------------------
/hedgehog-docs/blog/2019-05-28-first-blog-post.md:
--------------------------------------------------------------------------------
1 | ---
2 | slug: first-blog-post
3 | title: First Blog Post
4 | authors:
5 | name: Gao Wei
6 | title: Docusaurus Core Team
7 | url: https://github.com/wgao19
8 | image_url: https://github.com/wgao19.png
9 | tags: [hola, docusaurus]
10 | ---
11 |
12 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
13 |
--------------------------------------------------------------------------------
/hedgehog-docs/blog/2021-08-01-mdx-blog-post.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | slug: mdx-blog-post
3 | title: MDX Blog Post
4 | authors: [slorber]
5 | tags: [docusaurus]
6 | ---
7 |
8 | Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/markdown-features), such as [MDX](https://mdxjs.com/).
9 |
10 | :::tip
11 |
12 | Use the power of React to create interactive blog posts.
13 |
14 | ```js
15 | alert('button clicked!')}>Click me!
16 | ```
17 |
18 | alert('button clicked!')}>Click me!
19 |
20 | :::
21 |
--------------------------------------------------------------------------------
/hedgehog-docs/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg
--------------------------------------------------------------------------------
/hedgehog-docs/blog/2021-08-26-welcome/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | slug: welcome
3 | title: Welcome
4 | authors: [slorber, yangshun]
5 | tags: [facebook, hello, docusaurus]
6 | ---
7 |
8 | [Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog).
9 |
10 | Simply add Markdown files (or folders) to the `blog` directory.
11 |
12 | Regular blog authors can be added to `authors.yml`.
13 |
14 | The blog post date can be extracted from filenames, such as:
15 |
16 | - `2019-05-30-welcome.md`
17 | - `2019-05-30-welcome/index.md`
18 |
19 | A blog post folder can be convenient to co-locate blog post images:
20 |
21 | 
22 |
23 | The blog supports tags as well!
24 |
25 | **And if you don't want a blog**: just delete this directory, and use `blog: false` in your Docusaurus config.
26 |
--------------------------------------------------------------------------------
/hedgehog-docs/blog/authors.yml:
--------------------------------------------------------------------------------
1 | endi:
2 | name: Endilie Yacop Sucipto
3 | title: Maintainer of Docusaurus
4 | url: https://github.com/endiliey
5 | image_url: https://github.com/endiliey.png
6 |
7 | yangshun:
8 | name: Yangshun Tay
9 | title: Front End Engineer @ Facebook
10 | url: https://github.com/yangshun
11 | image_url: https://github.com/yangshun.png
12 |
13 | slorber:
14 | name: Sébastien Lorber
15 | title: Docusaurus maintainer
16 | url: https://sebastienlorber.com
17 | image_url: https://github.com/slorber.png
18 |
--------------------------------------------------------------------------------
/hedgehog-docs/developer/hedgehog-canvas-components.md:
--------------------------------------------------------------------------------
1 | # Hedgehog Canvas Components
2 |
3 | This package can be used to render the output of the hedgehog compiler result easily.
4 |
5 | ## Installation
6 |
7 | ```bash
8 | yarn install @hedgehogcomputing/canvas
9 | # or
10 | npm install @hedgehogcomputing/canvas
11 | ```
12 |
13 | ## Usage
14 |
15 | > `outputItem` is the output of the hedgehog compiler(hedgehog-core)
16 |
17 | ```jsx
18 | import Output from "@hedgehogcomputing/canvas/src/Output";
19 |
20 | const Results = () => {
21 | return (
22 | <>
23 |
24 | >
25 | )
26 | }
27 | ```
--------------------------------------------------------------------------------
/hedgehog-docs/developer/hedgehog-lab-components.md:
--------------------------------------------------------------------------------
1 | # Hedgehog Lab Components
2 |
3 | We are developing a set of components for the hedgehog Lab. These components are designed to be used in the hedgehog Lab and can be used in other projects as well.
4 |
5 | ## Installation
6 |
7 | ```bash
8 | yarn install @hedgehogcomputing/lab
9 | # or
10 | npm install @hedgehogcomputing/lab
11 | ```
12 |
13 | ## Usage
14 |
15 | ```jsx
16 | import HedgehogLab from "@hedgehogcomputing/lab/src/HedgehogLab";
17 |
18 | const Draft = () => {
19 | const yourSource = "any string"
20 | return (
21 | <>
22 |
23 |
24 | >
25 | )
26 | }
27 | ```
28 |
29 | ## API
30 | ` ` accepts the following props:
31 |
32 | -- alternative
33 | * source: `string` - the source code to be displayed in the editor
34 | * userSnippet : `string`- the user snippet to be displayed in the editor, example: "@username/snippet"
35 |
36 | -- common
37 | * defaultFullScreen: `boolean` - whether the editor should be displayed in full screen mode by default
38 | * defaultLiveMode: `boolean` - whether the compiler should be auto-reload in live mode by default
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-basics/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Tutorial - Basics",
3 | "position": 2,
4 | "link": {
5 | "type": "generated-index",
6 | "description": "5 minutes to learn the most important Docusaurus concepts."
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-basics/congratulations.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 6
3 | ---
4 |
5 | # Congratulations!
6 |
7 | You have just learned the **basics of Docusaurus** and made some changes to the **initial template**.
8 |
9 | Docusaurus has **much more to offer**!
10 |
11 | Have **5 more minutes**? Take a look at **[versioning](../tutorial-extras/manage-docs-versions.md)** and **[i18n](../tutorial-extras/translate-your-site.md)**.
12 |
13 | Anything **unclear** or **buggy** in this tutorial? [Please report it!](https://github.com/facebook/docusaurus/discussions/4610)
14 |
15 | ## What's next?
16 |
17 | - Read the [official documentation](https://docusaurus.io/).
18 | - Add a custom [Design and Layout](https://docusaurus.io/docs/styling-layout)
19 | - Add a [search bar](https://docusaurus.io/docs/search)
20 | - Find inspirations in the [Docusaurus showcase](https://docusaurus.io/showcase)
21 | - Get involved in the [Docusaurus Community](https://docusaurus.io/community/support)
22 |
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-basics/create-a-blog-post.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Create a Blog Post
6 |
7 | Docusaurus creates a **page for each blog post**, but also a **blog index page**, a **tag system**, an **RSS** feed...
8 |
9 | ## Create your first Post
10 |
11 | Create a file at `blog/2021-02-28-greetings.md`:
12 |
13 | ```md title="blog/2021-02-28-greetings.md"
14 | ---
15 | slug: greetings
16 | title: Greetings!
17 | authors:
18 | - name: Joel Marcey
19 | title: Co-creator of Docusaurus 1
20 | url: https://github.com/JoelMarcey
21 | image_url: https://github.com/JoelMarcey.png
22 | - name: Sébastien Lorber
23 | title: Docusaurus maintainer
24 | url: https://sebastienlorber.com
25 | image_url: https://github.com/slorber.png
26 | tags: [greetings]
27 | ---
28 |
29 | Congratulations, you have made your first post!
30 |
31 | Feel free to play around and edit this post as much you like.
32 | ```
33 |
34 | A new blog post is now available at `http://localhost:3000/blog/greetings`.
35 |
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-basics/create-a-document.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Create a Document
6 |
7 | Documents are **groups of pages** connected through:
8 |
9 | - a **sidebar**
10 | - **previous/next navigation**
11 | - **versioning**
12 |
13 | ## Create your first Doc
14 |
15 | Create a markdown file at `docs/hello.md`:
16 |
17 | ```md title="docs/hello.md"
18 | # Hello
19 |
20 | This is my **first Docusaurus document**!
21 | ```
22 |
23 | A new document is now available at `http://localhost:3000/docs/hello`.
24 |
25 | ## Configure the Sidebar
26 |
27 | Docusaurus automatically **creates a sidebar** from the `docs` folder.
28 |
29 | Add metadata to customize the sidebar label and position:
30 |
31 | ```md title="docs/hello.md" {1-4}
32 | ---
33 | sidebar_label: 'Hi!'
34 | sidebar_position: 3
35 | ---
36 |
37 | # Hello
38 |
39 | This is my **first Docusaurus document**!
40 | ```
41 |
42 | It is also possible to create your sidebar explicitly in `sidebars.js`:
43 |
44 | ```js title="sidebars.js"
45 | module.exports = {
46 | tutorialSidebar: [
47 | {
48 | type: 'category',
49 | label: 'Tutorial',
50 | // highlight-next-line
51 | items: ['hello'],
52 | },
53 | ],
54 | };
55 | ```
56 |
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-basics/create-a-page.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # Create a Page
6 |
7 | Add **Markdown or React** files to `src/pages` to create a **standalone page**:
8 |
9 | - `src/pages/index.js` -> `localhost:3000/`
10 | - `src/pages/foo.md` -> `localhost:3000/foo`
11 | - `src/pages/foo/bar.js` -> `localhost:3000/foo/bar`
12 |
13 | ## Create your first React Page
14 |
15 | Create a file at `src/pages/my-react-page.js`:
16 |
17 | ```jsx title="src/pages/my-react-page.js"
18 | import React from 'react';
19 | import Layout from '@theme/Layout';
20 |
21 | export default function MyReactPage() {
22 | return (
23 |
24 | My React page
25 | This is a React page
26 |
27 | );
28 | }
29 | ```
30 |
31 | A new page is now available at `http://localhost:3000/my-react-page`.
32 |
33 | ## Create your first Markdown Page
34 |
35 | Create a file at `src/pages/my-markdown-page.md`:
36 |
37 | ```mdx title="src/pages/my-markdown-page.md"
38 | # My Markdown page
39 |
40 | This is a Markdown page
41 | ```
42 |
43 | A new page is now available at `http://localhost:3000/my-markdown-page`.
44 |
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-basics/deploy-your-site.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 5
3 | ---
4 |
5 | # Deploy your site
6 |
7 | Docusaurus is a **static-site-generator** (also called **[Jamstack](https://jamstack.org/)**).
8 |
9 | It builds your site as simple **static HTML, JavaScript and CSS files**.
10 |
11 | ## Build your site
12 |
13 | Build your site **for production**:
14 |
15 | ```bash
16 | npm run build
17 | ```
18 |
19 | The static files are generated in the `build` folder.
20 |
21 | ## Deploy your site
22 |
23 | Test your production build locally:
24 |
25 | ```bash
26 | npm run serve
27 | ```
28 |
29 | The `build` folder is now served at `http://localhost:3000/`.
30 |
31 | You can now deploy the `build` folder **almost anywhere** easily, **for free** or very small cost (read the **[Deployment Guide](https://docusaurus.io/docs/deployment)**).
32 |
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-extras/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Tutorial - Extras",
3 | "position": 3,
4 | "link": {
5 | "type": "generated-index"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-extras/img/docsVersionDropdown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/docs/tutorial-extras/img/docsVersionDropdown.png
--------------------------------------------------------------------------------
/hedgehog-docs/docs/tutorial-extras/img/localeDropdown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/docs/tutorial-extras/img/localeDropdown.png
--------------------------------------------------------------------------------
/hedgehog-docs/math/Basic Operations/Dot Divide.draft:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `dot_divide(input1: any[] | Mat | Tensor, input2: any[] | Mat | Tensor) : any[] | Mat | Tensor`
5 |
6 | **param** `input1` first input, the numerator
7 |
8 | **param** `input2` second input, the denominator
9 |
10 | **returns:** `any[] | Mat | Tensor` - A copy of the resulting structure of element-wise divided values.
11 |
12 | This function takes two structures matrices, arrays, vectors, tensors of the same size and divides them element wise :
13 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Basic Operations/Dot Multiply.draft:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `dot_multiply(input1: any[] | Mat | Tensor, input2: any[] | Mat | Tensor) : any[] | Mat | Tensor`
5 |
6 | **param** `input1` first input, the first multiplicand
7 |
8 | **param** `input2` second input, the second multiplicand
9 |
10 | **returns:** `any[] | Mat | Tensor` - A copy of the structure multiplied **element-wise** (Note: this is not a standard multiplication of matrices), similar to dot_divide
11 |
12 | This function, similar to dot_divide, takes two structures of the same sizes, divides the elements element-wise, and returns it:
13 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Basic Operations/bounds.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `bounds(dataIn: any[] | Mat | Tensor, dim: number) : Mat | any[]`
4 |
5 | **param** `dataIn` - series of `number`s, an `Array`, matrix/`Mat` or `Tensor` to get the min and max of
6 |
7 | **param** `dim` (optional, default=0), '0'-(bound of all), '1'-(bound of column), '2'-(bound of row)
8 |
9 | **returns:** `Mat | any[]` - 1-D array or 2-D matrix - [min, max] or [[min1, min2], [max1, max2]], [[min1, max1], [min2, max2]]
10 |
11 | This function finds the minimum and maximum value of the given `dataIn`, which is a series of `number`s, an `Array`, a matrix/`Mat` or `Tensor`.
12 |
13 | For 2-D `Arrays`/`Mat` objects, you can use the `dim` parameter to determine if you get the bounds of all values or according to a row or column.
14 |
15 |
18 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Basic Operations/ceil.draft:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `ceil(input: any[] | Mat | Tensor) : Number | any[] | Mat | Tensor`
5 |
6 | **param** `input` a number, or an array, matrix, tensor to get the ceiling.
7 |
8 | **returns** `Number | any[] | Mat | Tensor` - the ceiling value of the element or elements, element-wise
9 |
10 | This function simply finds the ceiling of numbers. For example ceil(1.5) = 2, ceil(-1.5) = -1. This can also find the ceiling of numbers element-wise, given a 1d array, 2d array, Mat object, Tensor or just a list of numbers such as this:
11 | ceil(1.5,-1.5) = 2,-1.
12 |
13 |
14 |
18 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Basic Operations/check_input.draft:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `check_input(input: JS array)`
4 |
5 | **param** `input` JS array
6 |
7 | **returns** - true if input is 1-d or 2-d
8 |
9 |
10 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Basic Operations/factorial.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `factorial(dataIn: number[] | number[][] | Mat | Tensor | number) : number | any[] | Mat | Tensor`
4 |
5 | **param** `dataIn` The structure to find the factorial of (element-wise manner). Can be a `number`, `Mat`, `Array` or `Tensor`
6 |
7 | **returns:** `any[] | Mat | Tensor | number` - In the case of a `number` it returns the standard `dataIn!`. In the case of a different structure, it returns a copy of the matrix with each element replaced by its factorial, i.e. **element-wise** factorial. Recall that a factorial of a `number` is `number!=number*number-1*number-2*...*2*1`
8 |
9 |
10 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Basic Operations/floor.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `floor(dataIn: number | any[] | Mat | Tensor) : number | any[] | Mat | Tensor`
5 |
6 | **param** `dataIn` - the construct to find the floor of its numbers, element-wise.
7 |
8 | **returns:** `number | any[] | Mat | Tensor` - The construct with the elements reflected as their floor values
9 |
10 | The floor of a number is the closest **integer** below that number. For example, the closest integer below 5 is, well, 5. The closest integer below 5.9 is 5. The closest below 6.0001 is 6. This function takes in a `number`, list, matrix, `Mat` or `Tensor` and finds the floor of all elements and returns the `dataIn` construct with all the elements now being the floor elements.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Basic Operations/sum.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `sum(dataIn: any[] | Mat | Tensor | number) : any[] | Mat | Tensor | number`
5 |
6 | **param** `dataIn` the list, vector, Array/`Mat` or `Tensor`, or even `number` to sum the elements of
7 |
8 | **returns:** `number` - A `number` which is the sum of all the elements of each entry in the structure `dataIn`
9 |
10 | This function sums all elements of a given structure and returns that sum:
11 |
12 |
15 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Data/any_missing.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `any_missing(matrix: any[] | Mat | Tensor) : boolean`
5 |
6 | **param** `matrix` - The inputted matrix to check for any missing data
7 |
8 | **returns:** `boolean` - `true` if there is at least 1 missing element, `false` otherwise
9 |
10 | This function goes through the data, whether it be a list, `Array`, etc and checks for missing values. Missing values are namely, `NaN`, `null`, `''`, and `undefined`. Note that `[]` and `{}` are not considered missing. Hence it will comb through the data searching for these 4 types of missing values and if it returns `true` at least once, it will return that there is missing values.
11 |
12 | This is useful for searching in a large `Array` and should be standard. If not done, you may get an error and that error may not be understood to be coming from the missing elements. Below is some smaller scale examples of how to use this function.
13 |
14 |
15 |
16 |
19 |
20 | A common usage of this concept is when importing large data files and translating them such as csv files, you may end up with a lot of `null` or `NaN` entries.
--------------------------------------------------------------------------------
/hedgehog-docs/math/Data/is_local_max.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `is_local_max(matrix: any[] | Mat | Tensor, dim: number) : Mat | Tensor`
5 |
6 |
7 | **param** `matrix` - an `Array`, `Mat` or `Tensor`, i.e. the construct to find the local maximum value of the input.
8 |
9 | **param** `dim` - '0' (row) or '1' (column) - the direction to go across in finding the local maxima
10 |
11 | **returns** `Mat | Tensor` - a `Mat` or `Tensor` with '1' denoting the local max value is there and '0' denoting that it is not a local maxima.
12 |
13 | Note that if `dim` is '1', then `matrix` must be at least a 2-D input.
14 |
15 | This function finds all the local maximum value **locations** of the input.
16 |
17 |
20 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Data/is_local_min.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `is_local_min(matrix: any[] | Mat | Tensor, dim: number) : Mat | Tensor`
5 |
6 |
7 | **param** `matrix` an `Array`, `Mat` or `Tensor`, i.e. the structure to find the local minima locations
8 |
9 | **param** `dim` '0'-(row) or '1'-(column) - the direction to traverse for finding the local minima
10 |
11 | **returns** - `Mat | Tensor` - a `Mat` or `Tensor` with '1' denoting a local min value and '0' denoting otherwise.
12 |
13 | Notice if `dim` is 1, then `matrix` must be at least 2-D.
14 |
15 | This function finds all the local minimum value **locations** of the input.
16 |
17 |
20 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Data/is_missing.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `is_missing(matrix: any[] | Mat | Tensor) : any[] | Mat | Tensor`
5 |
6 | **param** `matrix` - the `Array`, `Mat`, or `Tensor` where you want to find a missing element(s).
7 |
8 | **returns:** `any[] | Mat | Tensor` - A copy of `matrix`, where each element is '1' if missing, '0' if not.
9 |
10 | This function effectively takes your input, which is a `Mat`, `Tensor` or `Array`, and if it has a missing value in that entry it puts a '1' in that entry. If it is not a missing value, it sets it to '0'. So you get returned a corresponding structure of what you put in `matrix` with 0's and 1's, where 1's represent missing elements and 0's otherwise.
11 |
12 | Note that `NaN`, `null`, `''` and `undefined` are defined to be missing but `[]` and `{}` are not.
13 |
14 | This is useful for **knowing** where the missing elements are but not having an effect on them yet.
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Data/missing.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `missing(matrix: any[] | Mat | Tensor, dim: number, times: number) : any[] | Mat | Tensor`
5 |
6 | **param** `matrix` - The input matrix, `Tensor`, `Mat`, etc that gets added missing space to it
7 |
8 | **param** `dim` - '0' or '1' - 0 means row and 1 means column. This is where you create the extra space
9 |
10 | **param** `times` - how many rows / columns to create
11 |
12 | **returns:** `any[] | Mat | Tensor` - A copy of the input with extra blank (**missing**) rows or columns (based on parameter `dim` with the amount based on parameter `times`).
13 |
14 | This function creates a copy of your input with extra space, which is missing space.
15 |
16 | Note that `null`, `NaN`, `''` and `undefined` are defined to be missing values. `[]` and `{}` are not.
17 |
18 | This is useful in combination with the function `fill_missing`.
19 |
20 |
21 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Data/normalize.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `normalize(matrix: any[] | Mat | Tensor) : Mat | Tensor`
5 |
6 |
7 | **param** `matrix`- an `Array`, matrix or `Tensor`, or a series of `number`s (a list), i.e. the construct of data to be normalized
8 |
9 | **returns** - `Mat | Tensor` - a `Mat` or `Tensor` with all the values inside normalized to the range [0,1].
10 |
11 | This function **normalizes** the data. It performs normalization on the data whether its in a matrix structure or in a series of `number`s. Effectively, it takes the values and reduces them to various values in the interval [0,1]. For example, (1,2,3) would be normalized as (0,0.5,1).
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Data/rm_missing.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `rm_missing(matrix: any[] | Mat | Tensor, dim: number) : any[] | Mat | Tensor`
5 |
6 | **param** `matrix` - the input to remove the missing values of
7 |
8 | **param** `dim` '0' or '1' : 0 means delete the whole column, 1 means delete the whole row. Default is '0'.
9 |
10 | **returns:** `any[] | Mat | Tensor` - returns the corresponding input with missing values removed.
11 |
12 | This function takes the input, and deletes the columns (default) or rows (if `dim=1`) that have missing values. Note that this also deletes some valid values in most cases.
13 |
14 | Also, note that `null`, `NaN`, `''` and `undefined` are defined to be missing values. `[]` and `{}` are not.
15 |
16 | This is useful when you simply want to remove missing data values and not handle it. This can perhaps be appropriate for a very large `Array` where the missing values are sparse and you dont want to fill it with false values.
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Data/smooth.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `smooth(matrix: any[] | Mat | Tensor, dim: number) : any[] | Mat | Tensor`
5 |
6 | **param** `matrix` - an `Array`, `Mat` or `Tensor` only supporting 2-D, to smooth the data of.
7 |
8 | **param** `dim` either '0' or '1', '0' for rows, '1' for columns. Default is rows, `dim=0`.
9 |
10 | **returns:** `any[] | Mat | Tensor` - a copy of the input with the elements smoothed.
11 |
12 | This function smooths the data by the following method:
13 |
14 | `a[i] -> (a[i - 2] + a[i - 1] + a[i] + a[i + 1] + a[i + 2]) / 5`
15 |
16 | An example to make it clearer is shown below. It's useful for cases where the data is very noisy in large data sets, or where there are many outliers.
17 |
18 | Overall it tries to make the data all "closer" together, or less eratic.
19 |
20 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Decompositions/QR.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `QR(matrix: any[] | Mat) : any[]`
5 |
6 | **param** `matrix` - The matrix to be decomposed using the QR method. Needs to be a square matrix.
7 |
8 | **returns:** `any[]` - An object holding the matrices `Q` and `R`. Access them via `{result}.Q`
9 |
10 | This function decomposes a square matrix using the QR method, where Q is an orthogonal matrix and R is an upper triangular matrix. Note that an orthogonal matrix is one where the rows and columns are orthonormal vectors which is satisfied by Q^TxQ = QxQ^T = I, where I is identity). Knowing when one decomposition is better than the other is key to saving time and being efficient with data.
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Decompositions/cholesky.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `cholesky(matrix: any[] | Mat) : any[]`
5 |
6 | **param** `matrix` - The matrix to decompose using the Cholesky method. Needs to be symmetric (hermitian) and positive definite (if the number `z^T*M*z > 0` for every non-zero column vector z for `M=input`, but one can ignore these details).
7 |
8 | **returns:** `any[]` - An object holding the matrix `L` from the decomposition `L*L^T = matrix`. Accessed via `{result}.L`.
9 |
10 | This function decomposes a positive definite, symmetric (hermitian) matrix using the Cholesky method. It return and object with member `L`, where `L` is part of the decomposition, `L*L^T = A` where `A` would be the input. If the input is not positive definite an exception will be thrown.
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Decompositions/lup.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `lup(matrix: any[] | Mat) : any[]`
5 |
6 | **param** `matrix` - The matrix to be decomposed using the LU method. Needs to be a square matrix.
7 |
8 | **returns:** `any[]` - The matrix `L` , `U` and the column vector `p` from the decomposition.
9 |
10 | This function decomposes a square matrix using the LU decomposition method. It returns a lower triangular matrix (L), an upper triangular matrix (U), and pivot (p). Note that these can be access by calling `{result}.L, {result}.U, {result}.p` as we'll see in the following example. This is because the return value is an object with members L, U and p.
11 |
12 |
13 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Linear Equation Systems/lsolve.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `lsolve(A: any[] | Mat, b: any[] | Mat) : any[]`
5 |
6 | **param** `A` - The 'A' part of `Ax=b`. A 2-D matrix, specifically a **lower triangular** one. See `lusolve` or `usolve` for variants.
7 |
8 | **param** `b` - The 'b' part of `Ax=b`. A 1-D matrix, must be a column vector specifically. `[ [1], [2], [3]]` for example.
9 |
10 | **returns:** `any[]` - The column vector representing the solution to the equation `Ax=b`, or the part, `x`.
11 |
12 | This function finds the answer to the equation `Ax=b`, or the linear equation system where `x` is a column vector of the different variables.
13 |
14 |
15 |
18 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Linear Equation Systems/lusolve.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `lusolve(A: any[] | Mat, b: any[] | Mat) : any[]`
5 |
6 | **param** `A` - The 'A' part of `Ax=b`. A 2-D matrix. See `lsolve` or `usolve` for variants.
7 |
8 | **param** `b` - The 'b' part of `Ax=b`. A 1d-D matrix, must be a column vector specifically. `[[1], [2], [3]]` for example.
9 |
10 | **returns:** `any[]` - The column vector representing the solution to the equation `Ax=b`, or the part, `x`.
11 |
12 | This function finds the answer to the equation `Ax=b`, or the linear equation system where `x` is a column vector of the different variables. Can be less efficient than `lsolve()` or `usolve()` but works for non-triangular matrices.
13 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Linear Equation Systems/usolve.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `usolve(A: any[] | Mat, b: any[] | Mat) : any[]`
5 |
6 | **param** `A` - The 'A' part of `Ax=b`. A 2-D matrix, specifically **upper triangular**. See `lusolve` or `lsolve` for variants.
7 |
8 | **param** `b` - The 'b' part of `Ax=b`. A 1-D matrix, must be the column vector specifically.
9 |
10 | **returns:** `any[]` - The column vector representing the solution to the equation `Ax=b`, or the part, `x`.
11 |
12 | This function finds the answer to the equation `Ax=b`, or the linear equation system where `x` is a column vector of the different variables.
13 |
14 |
17 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Misc/all.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `all()`
5 |
6 | **param** none
7 |
8 | **returns** none
9 |
10 | This function is useful if you don't want to handpick what functions to import. It *imports all math functions* from the math library (including all discussed in this reference) into the Hedgehog Lab instance.
11 |
12 |
15 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Misc/deep_copy.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `deep_copy(input: number | any[] ) : number | any[]`
5 |
6 | **param** `input` - the `number` or `Array` your want a deep copy of, i.e. a new reference.
7 |
8 | **returns:** `number | any[] ` - a replicate of the input but with a different reference.
9 |
10 | This function is very useful for many functions that need to modify parameters or other ``Array``s. Since there is no way of cloning an `Array` in a deep way, we have to write a way ourselves.
11 |
12 | For example, even if you created a new `Array` and copied all the items from the original `Array` to the new `Array`, the new `Array` would still have the reference to the original `Array` causing issues when modifying the new `Array` and trying to access the old `Array` - because the old `Array` would now be updated too. This prevents that.
13 |
14 | Overall, if you need an `Array` that is an **independent**, non-shallow copy of another `Array`, simply call `deep_copy(Array_to_copy)`. Then when you modify this new, independent `Array`, it will not interfere in any manner with `Array_to_copy`.
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Misc/test.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `test()`
5 |
6 | **param** - none
7 |
8 | **returns:** none
9 |
10 | This function runs all "tests", for all the math functions in the math library. It may take a while. The tests for each function are not in this reference book.
11 |
12 | Similar to `all()` this will import all the test functions and **run them**. For each function there is a test function named `{functionname}_test.hhs` that throws an exception if it fails. If it passes nothing happens.
13 |
14 |
15 |
16 |
19 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Probability and Statistics/iqr.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `iqr(matrix1: any[] | Mat | Tensor) : number`
4 |
5 | **param** `matrix1` an `Array`, `Mat` or `Tensor` (or a series of numbers) to find the inter-quartile range of
6 |
7 | **returns** - `number` - representing the inter-quartile range value.
8 |
9 | The inter-quartile range, or the *midspread* or *middle 50%*, is the difference between the 75th and 25th percentiles of the data. Hence, this function takes data from a construct, whether it is a series of numbers, an `Array`, `Mat` or `Tensor` and finds the 75% and 25% percentiles, namely 'q1' and 'q3', (the 1st and 3rd *quantiles*) for 0.25 and 0.75. Then we return 'q3-q1' to end up with the iqr or middle 50% of the data. (can be called 'q2').
10 |
11 |
12 |
15 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Probability and Statistics/max.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `max(dataIn: number | any[] | Mat | Tensor) : number`
5 |
6 | **param** `dataIn` The structure to find the maximum element of.
7 |
8 | **returns:** `number` - representing the maximum value of the structure given
9 |
10 | This function is similar to min, it finds the maximum element in a given structure, whether its a list, `Array`, `Mat`, `Tensor` or even a `number` itself (the trivial case). Overall, it's finding the largest element of a structure.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Probability and Statistics/mean.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `mean(matrix: any[] | Mat | Tensor) : number`
4 |
5 | **param** `matrix` - an `Array`, `Mat` or `Tensor`, that contains the data for finding the mean
6 |
7 | **returns** - `number` - representing the mean (sometimes called the average) of `matrix`'s elements
8 |
9 | This function finds the mean of the data given in `matrix`. The mean is the sum of all elements, divided by the number of elements. It can be thought of as the 'center' of the data, as it accounts all values, high and low and tries to go in the middle.
10 |
11 | Note that the mean is prone to abuse by data that is very extreme, such as outliers or repetition. Suppose you have a data set of [2,3,4,2,3,100,2]. The 100 is clearly extreme, an outlier, and this will affect the mean dramatically. There are methods that reduce this inconsistency by removing or performing other operations on outliers.
12 |
13 | The mean is similar to the median. They are both measurements of the 'center' of data sets.
14 |
15 |
18 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Probability and Statistics/median.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `median(matrix: any[] | Mat | Tensor) : number`
4 |
5 | **param** `matrix` an - `Array`, `Mat` or `Tensor`, holding the data to find the median.
6 |
7 | **returns** - `number` - representing the median of `matrix`
8 |
9 | This function finds the median of the input data. The median is one of a few ways to describe the 'center' of data. Another is 'mean' i.e. the average. Try to think of all the numbers of `matrix` lined up in order. Then simply take the middle one! If there's two in the middle, take the sum of them, divided by 2 (i.e. the average of them).
10 |
11 | Again, this is a descriptive statistic method of finding the 'center' of data. The advantage here over the mean is outliers don't make an impact because they're just removed automatically. The disadvantage is the true center may be less accurately represented because only 1 item is taken into account, so the median doesnt take into account the weights other members play into the center.
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Probability and Statistics/min.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `min(dataIn: number | any[] | Mat | Tensor) : number`
5 |
6 | **param** `dataIn` - a `number`, an `Array`, `Mat` or `Tensor`, where you want to find the minimum value.
7 |
8 | **returns:** `number` - representing the minimum value of the structure given
9 |
10 | This function is similar to `max()` - it finds the minimum element in a given structure, whether its a list, `Array`, `Mat` or `Tensor`, or even a number itself (the trivial case). Overall, it's finding the smallest element of a set.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Probability and Statistics/multinomial.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `multinomial(matrix1: any[] | Mat | Tensor ) : number`
4 |
5 | **param** `matrix1` an `Array`, `Mat`, `Tensor`, or a series of numbers - the construct to find the multinomial coeff. of
6 |
7 | **returns** `Number` - a number representing the multinomial of `matrix1`
8 |
9 | This function finds the multinomial coefficient of numbers in a data structure according to the formula below. One can think of it as an analogue for the binomial probability distribution and its coefficients. However, this is for the multinomial case.
10 |
11 |
12 | {"$$\\text{multinomial}(x) = \\frac{(x_1 + x_2 + ... + x_n)!}{x_1!\\cdot x_2!\\cdot ... \\cdot x_n!}$$"}
13 |
14 |
15 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Probability and Statistics/rms.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `rms(matrix: any[] | Mat | Tensor) : number`
4 |
5 | **param** `matrix` - an `Array`, `Mat` or `Tensor`, to find the root mean square of.
6 |
7 | **returns** - `number` - representing the root mean square value
8 |
9 | The root mean square is a tool used in a variety of statistical analyses, including but not limited to RMSE (root mean square deviation), variance and more. Overall, it's the square root of the mean in which ech mean variable value is squared. The formula and an example is below:
10 |
11 | The root mean square formula is as follows (rms):
12 |
13 | {"$$r = \\sqrt{\\frac{x_1^2 + ... + x_n^2}{n}}$$"}
14 |
15 |
16 |
19 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/det.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `det(matrix: any[] | Mat) : number`
5 |
6 | **param** `matrix` - An `Array` or `Mat`, should be square.
7 |
8 | **returns:** `number` - represents the determinant of the `matrix`. One useful tool of the determinant is determining if a matrix is invertible: if the determinant is *not* zero then it is invertible.
9 |
10 | This function returns the determinant of a square matrix.
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/is_diag.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `is_diag(matrix: any[] | Mat) : boolean`
5 |
6 | **param** `matrix` - an `Array` or `Mat` to check if it's diagonal or not.
7 |
8 | **returns:** `boolean` - `true` if diagonal, `false` otherwise
9 |
10 | A diagonal matrix is similar to the identity matrix but the diagonal entries are free to have any number in them (unlike identity which has all 1's on the diagonal) and 0's elsewhere. Connected concepts are the upper triangular and lower triangular matrices which are also within this book. This function specifically takes in any 2-D `Array` or `Mat` object as an input and determines whether it's diagonal or not.
11 |
12 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/is_number.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `is_number(input: any): boolean`
5 |
6 | **param** `input` - Anything to test if it is of type `number` or not
7 |
8 | **returns:** - `boolean` - `true` if it is a `number`, `false` otherwise. `Infinity` and `NaN` are defined to **not** be numbers in Hedgehog Lab. You can use hex and binary inputs as numbers - 0xff10 etc.
9 |
10 | This function tests if the input is a number or not. It does not allow strings, infinity, NaN. It also checks type.
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/is_symmetric.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `is_symmetric(matrix: any[] | Mat) : boolean`
5 |
6 | **param** `matrix` - Any matrix, 2 dimensional and square, to test if it's symmetric or not.
7 |
8 | **returns:** - `boolean` - `true` if it is symmetric, `false` otherwise
9 |
10 | This function tests if a square 2-D matrix is symmetric or not. A symmetric matrix has the property that swapping rows and columns doesn't change the matrix. This also means that the matrix's transpose is equal to itself. One way to visually check is look at the diagonal - if the elements are symmetric across that, it is symmetric.
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/is_tril.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `is_tril(matrix: any[] | Mat) : boolean`
5 |
6 | **param** `matrix` - Any matrix, must be 2 dimensional and square, to test if it's lower triangular or not
7 |
8 | **returns:** `boolean` - `true` if it is lower triangular, `false` otherwise.
9 |
10 | This function tests if a square 2-D matrix is lower triangular or not. Lower triangular matrices have the property that above the diagonal, all values are zero. Thus one can look at the diagonal and see if theres any entry above the diagonal that is non zero. If there is, it is **not** lower triangular.
11 |
12 |
13 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/is_triu.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `is_triu(matrix: any[] | Mat) : boolean`
5 |
6 | **param** `matrix` - Any matrix, 2 dimensional and square, to test if it's an upper triangular matrix or not
7 |
8 | **returns:** `boolean` - `true` if it is upper triangular, `false` otherwise.
9 |
10 | This function tests if a square 2-D matrix is upper triangular or not. Upper triangular matrices have the property that everything *below* the diagonal is zero, hence only the upper diagonal (shaped like a triangle) has values. For a visual method, look at the diagonal and see if there's any entry below the diagonal that is non zero. If there is, it is *not* upper triangular.
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/ndim.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `ndim(dataIn: any[] | Mat | Tensor | number) : number`
5 |
6 | **param** `dataIn` - an `Array`, `Mat` or `Tensor` or even a `number`.
7 |
8 | **returns:** `number` - Representing the dimension of the structure.
9 |
10 | This function is quite useful as it can handle different cases when size matters. It determines the number of dimensions of a structure. For example, a vector is 1 dimensional. A 2-D array is 2 dimensional. A 3-D `Array` or 3-D `Tensor` has 3 dimensions and so on. A `number` has 0 dimensions.
11 |
12 | Note that this is returning the **number** of dimensions, not the dimensions themselves. So for a matrix of size 3x4, it has 2 dimensions - rows and columns. Thus `ndim=2`, the size of 3x4 doesn't matter in this function.
13 |
14 |
17 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/shape.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `shape(matrix: any[] | Mat | Tensor) : any[]`
5 |
6 | **param** `matrix` - The construct you want to find the shape of, should be an `Array`, `Mat` or `Tensor.
7 |
8 | **returns:** `any[]` - A row vector specifying the shape. And in the row vector, the numbers in each index represent the length of each dimension. For example a return value of [3,4] means the shape of the construct was a 3x4 matrix. A return value of [10] means it has 1 dimension of size 10. That is a list with 10 elements.
9 |
10 | This function gives us the `shape` of various constructs whatever dimensions they have. The shape is a row vector that informs us of the lengths of each dimension of said construct. Another example is if it was a tensor with 5 dimensions, where dimension 1 had 3 rows, dimension 2 had 4 columns, dimension 3 had height 3, dimension 4 had length 2, and dimension 5 had length 4, we would have a shape of [3,4,3,2,4].
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Properties/trace.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `trace(matrix: any[] | Mat | Tensor) : number`
5 |
6 | **param** `matrix` - an `Array`, `Mat` or `Tensor`. Must be 2-D and square.
7 |
8 | **returns:** `number` - The trace of the matrix.
9 |
10 | This function returns the trace of the matrix given. The trace is the *sum of the diagonal entries* of a matrix. It is useful in certain applications and measurements of matrix properties.
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/flatten.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `flatten(matrix: any[] | Mat | Tensor) : any[]`
5 |
6 | **param** `matrix` - an `Array`, `Mat` or `Tensor`
7 |
8 | **returns:** `any[]` - A list with all elements from `matrix`. The order of elements follows the dimensions or shape order.
9 |
10 | This function is a useful tool for taking a multidimensional matrix, for example a 2-D matrix, and "flattening" it into a 1d `Array` i.e. a list. Here is an example:
11 |
12 |
13 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/hankel.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `hankel(list: any[]) : Mat`
5 |
6 | **param** `list` - A 1-D `Array` or just a series of numbers, **must** be odd in length.
7 |
8 | **returns:** `Mat` - A Hankel matrix. Where the skewing up-right diagonals are constant.
9 |
10 | This function constructs a Hankel matrix. A Hankel matrix is much easier understood when seen than when said. However, to explain it - if you take any element on the left hand side of the matrix and follow its diagonal in the up-right direction, it should be constant. An example is:
11 |
12 | ```js
13 | [[1, 2, 3],
14 | [2, 3, 4],
15 | [3, 4, 5]]
16 | ```
17 |
18 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/identity.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `identity(int: integer) : Mat`
5 |
6 | **param** `int` - an integer representing the size of the identity matrix you want to create. An identity matrix is square so if `int = 3`, you'll get a 3x3 matrix.
7 |
8 |
9 | **returns:** `Mat` - namely the identity matrix as a `Mat` object (matrix).
10 |
11 | This function creates an identity matrix of `int x int` size. An identity matrix has all diagonal values as 1's and everything else as 0's. It is important in many operations because any matrix multiplied by the identity matrix (to the left, or right) is equal to the matrix itself.
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/inv.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 |
5 | #### `inv(matrix: any[] | Mat) : any[]`
6 |
7 | **param** `matrix` a 2-D `Array` or `Mat`. Should be square and invertible.
8 |
9 | **returns:** `any[]` - The matrix that is the *inverse* of `matrix` i.e. `matrix * matrix^-1 = I` where `I` is the identity matrix. (recall identity matrix is 1's on the diagonal and 0's elsewhere)
10 |
11 | This function simply finds the inverse of a matrix if it's invertible. One test for invertible matrices is its invertible if the determinant is not zero. ( !(det(matrix) === 0 )
12 |
13 |
14 |
17 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/magic.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `magic(size: number) : Mat`
5 |
6 | **param** `size` - the `number` representing the size of the square magic matrix (dimension-wise). If `size = 4`, it'll generate a 4x4 "magic matrix".
7 |
8 | **returns:** `Mat` - a `Mat` of dimenions `size x size`, with the magic propeerties imbued making it a magic matrix.
9 |
10 | This function creates a magic matrix given a number, the size of the matrix to make. A magic matrix is one where the rows, columns, and main diagonals sum up to the same values. The magic matrix is square. An example is given in the section below. Try it out for different sizes.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/pascal.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 |
4 | #### `pascal(size: integer) : any[]`
5 |
6 | **param** `size` - the size of the pascal matrix, an `integer`, namely positive and not zero.
7 |
8 | **returns:** `any[]` - the pascal matrix corresponding to the size (dimension-wise) wwgiven for the square matrix.
9 |
10 | A pascal matrix has binomial coefficients as its entries. The binomial coefficients are the numbers in front of the variables for the expansion (a+b)^x, where x is variable. So for `x = 2`, `(a+b)^2 = (a+b)(a+b) = a^2+2ab+b^2 = (1)a^2 + (2)ab + (1)b^2`. Thus the coefficients for the case `x = 2` is 1,2,1. This function takes in a `number` as its size, and returns the pascal matrix corresponding to that size.
11 |
12 |
13 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/reshape.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `reshape(matrix: any[] | Mat | Tensor, sizes: any[]) : any[] | Mat | Tensor`
4 |
5 | **param** `matrix` - an `Array`, `Mat` or `Tensor` - the construct to reshape according to `sizes`.
6 |
7 | **param** `sizes` a 1-D `Array` (list) representing the size - dimension-wise.
8 |
9 | **returns** - `any[] | Mat | Tensor` - an `Array`, `Mat` or `Tensor` reshaped with the corresponding size given in `sizes`
10 |
11 | `size` should be something like `[2, 2, 2]` or `[2, -1]`. In the latter case, -1 means automatically matching.
12 |
13 |
16 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/resize.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `resize(matrix: any[] | Mat | Tensor, sizes: any[], defaultValue : number) : any[] | Mat | Tensor`
4 |
5 | **param** `matrix` - an `Array`, `Mat` or `Tensor` - the construct to be resized
6 |
7 | **param** `sizes` a 1-D `Array` (list) to resize to
8 |
9 | **param** `defaultValue` a number for filling the remaining empty spaces
10 |
11 | **returns** - `any[] | Mat | Tensor` - a resized `Array`, `Mat` or `Tensor` with the corresponding size given in `sizes`
12 |
13 | `sizes` should be something like `[2, 2, 2]` or `[2, -1]`. Here, -1 means automatically matching.
14 |
15 | `resize` and `reshape` are very similar. Here is an example for clarity:
16 |
17 |
20 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/transpose.mdx:
--------------------------------------------------------------------------------
1 |
2 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
3 |
4 | #### `transpose(matrix: any[] | Mat): any[]`
5 |
6 | **param** `matrix` - The `Array` or `Mat` to get the transpose of. Should be square and 2 dimensional.
7 |
8 | **returns:** `any[]` - An `Array` that is the transpose of `matrix`.
9 |
10 | This function returns a new matrix that is the transpose of `matrix`, which should be a 2-D, square matrix.
11 |
12 | A transpose of a matrix is the resulting matrix when you swap the rows and columns.
13 |
14 |
17 |
--------------------------------------------------------------------------------
/hedgehog-docs/math/Transformations and creations/vander.mdx:
--------------------------------------------------------------------------------
1 | import { MathJax, MathJaxContext } from 'better-react-mathjax'
2 |
3 | #### `vander(matrixData: any[] | Mat | Tensor, dim : number) : Mat`
4 |
5 | **param** `matrixData` - an `Array`, `Mat` or `Tensor`.
6 |
7 | **param** `dim` - the dimension, which should be >= 0.
8 |
9 | **returns** - `Mat` - a Vandermonde matrix
10 |
11 |
12 | A Vandermonde matrix is defined by a set of scalars, which in this case, come from the matrix given as the first parameter, and you can limit it by `dim`.
13 |
14 | An example to clarify is as follows:
15 |
16 |
17 | {"$$\\begin{bmatrix} 1 & x_1 & x_1^2 & ... & x_1^{dim} \\\\ . & . & . & . & . \\\\ . & . & . & . & .\\\\ . & . & . & . & .\\\\ 1 & x_n & x_n^2 & ... & x_n^{dim} \\end{bmatrix}$$"}
18 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/hedgehog-docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "my-website",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "docusaurus": "docusaurus",
7 | "start": "docusaurus start",
8 | "build": "docusaurus build",
9 | "swizzle": "docusaurus swizzle",
10 | "deploy": "docusaurus deploy",
11 | "clear": "docusaurus clear",
12 | "serve": "docusaurus serve",
13 | "write-translations": "docusaurus write-translations",
14 | "write-heading-ids": "docusaurus write-heading-ids"
15 | },
16 | "dependencies": {
17 | "@docusaurus/core": "2.0.0-beta.21",
18 | "@docusaurus/preset-classic": "2.0.0-beta.21",
19 | "@mdx-js/react": "^1.6.22",
20 | "better-react-mathjax": "^2.0.1",
21 | "clsx": "^1.1.1",
22 | "prism-react-renderer": "^1.3.3",
23 | "react": "^17.0.2",
24 | "react-dom": "^17.0.2"
25 | },
26 | "devDependencies": {
27 | "@docusaurus/module-type-aliases": "2.0.0-beta.21"
28 | },
29 | "browserslist": {
30 | "production": [
31 | ">0.5%",
32 | "not dead",
33 | "not op_mini all"
34 | ],
35 | "development": [
36 | "last 1 chrome version",
37 | "last 1 firefox version",
38 | "last 1 safari version"
39 | ]
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/hedgehog-docs/sidebars.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Creating a sidebar enables you to:
3 | - create an ordered group of docs
4 | - render a sidebar for each doc of that group
5 | - provide next/previous navigation
6 |
7 | The sidebars can be generated from the filesystem, or explicitly defined here.
8 |
9 | Create as many sidebars as you want.
10 | */
11 |
12 | // @ts-check
13 |
14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
15 | const sidebars = {
16 | // By default, Docusaurus generates a sidebar from the docs folder structure
17 | tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
18 |
19 | // But you can create a sidebar manually
20 | /*
21 | tutorialSidebar: [
22 | {
23 | type: 'category',
24 | label: 'Tutorial',
25 | items: ['hello'],
26 | },
27 | ],
28 | */
29 | /*sidebar: [
30 | {
31 | type: 'category',
32 | label: 'Hedgehog-Script',
33 | items: [
34 | {
35 | type:'doc',
36 | id:'introduction',
37 | label:'Introduction',
38 | },
39 | {
40 | type: 'doc',
41 | id: 'statementsdeclarations',
42 | label: 'Statements & Declarations',
43 | }
44 | ],
45 | },
46 | ],*/
47 | };
48 |
49 | module.exports = sidebars;
50 |
--------------------------------------------------------------------------------
/hedgehog-docs/src/components/HomepageFeatures/styles.module.css:
--------------------------------------------------------------------------------
1 | .features {
2 | display: flex;
3 | align-items: center;
4 | padding: 2rem 0;
5 | width: 100%;
6 | }
7 |
8 | .featureSvg {
9 | height: 200px;
10 | width: 200px;
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/hedgehog-docs/src/pages/index.module.css:
--------------------------------------------------------------------------------
1 | /**
2 | * CSS files with the .module.css suffix will be treated as CSS modules
3 | * and scoped locally.
4 | */
5 |
6 | .heroBanner {
7 | padding: 4rem 0;
8 | text-align: center;
9 | position: relative;
10 | overflow: hidden;
11 | }
12 |
13 | @media screen and (max-width: 996px) {
14 | .heroBanner {
15 | padding: 2rem;
16 | }
17 | }
18 |
19 | .buttons {
20 | display: flex;
21 | align-items: center;
22 | justify-content: center;
23 | }
24 |
--------------------------------------------------------------------------------
/hedgehog-docs/src/pages/markdown-page.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Markdown page example
3 | ---
4 |
5 | # Markdown page example
6 |
7 | You don't need React to write simple standalone pages.
8 |
--------------------------------------------------------------------------------
/hedgehog-docs/static/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/.nojekyll
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/browser_requirements_webgl.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/browser_requirements_webgl.jpg
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/community.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/community.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/docusaurus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/docusaurus.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/environment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/environment.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/execresults.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/execresults.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/execresults2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/execresults2.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/favicon.ico
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/features.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/features.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/githubIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/githubIcon.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/githubIcon_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/githubIcon_32x32.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/googleIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/googleIcon.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/googleIcon_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/googleIcon_32x32.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/hedgehog_1f994 copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/hedgehog_1f994 copy.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/hedgehog_1f994.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/hedgehog_1f994.ico
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/hedgehog_1f994.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/hedgehog_1f994.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/linkedinIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/linkedinIcon.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/linkedinIcon_16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/linkedinIcon_16x16.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/linkedinIcon_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/linkedinIcon_32x32.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/profilearea.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/profilearea.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/promises.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/promises.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/register3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/register3.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/registerHHL.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/registerHHL.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/resources.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/resources.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/timeline2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/timeline2.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/yourscript3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/yourscript3.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/yourscripts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/yourscripts.png
--------------------------------------------------------------------------------
/hedgehog-docs/static/img/yourscripts2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/hedgehog-docs/static/img/yourscripts2.png
--------------------------------------------------------------------------------
/hedgehog-libs/README.md:
--------------------------------------------------------------------------------
1 | # Hedgehog Library
2 |
3 | This is a library of essential core functions for Hedgehog Lab, including:
4 |
5 | - [math](./math/README.md), the core math library
6 | - [plot](./plot/README.md), the core plotting and data visualization library
7 | - [ml](./ml/README.md), the machine learning library
8 | - [std](./std/README.md), the standard library for some core functions and utilities
9 | - [datasets](./datasets/README.md), the datasets library
10 | - [network](./network/README.md), the network library
11 |
12 | Each of these libraries is documented in its own README.MD file.
13 |
14 | ## How to use this library?
15 |
16 | **No installation is needed.** Just check the documentation for each library and use it directly in Hedgehog Lab at [https://hlab.app](https://hlab.app/).
17 |
18 | For example, you can import and use the **LU Decomposition** function `lu(X)` from `math` library in this way:
19 |
20 | ```
21 | // 1. Import it
22 | *import math:lu
23 |
24 | // 2. Use it
25 | let L = lu([[2,3],[4,2]]).L;
26 | ```
27 | ## How do I contribute to this library?
28 |
29 | Just fork this repository and make a pull request with your functions added.
--------------------------------------------------------------------------------
/hedgehog-libs/math/QR_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function unit test for QR, makes sure it decomposes the right answer for both Q and R with hedgehog's built in tolerance level
7 | */
8 |
9 |
10 |
11 | function QR_test() {
12 |
13 | *import math: QR
14 |
15 | if (QR([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]]).R.val === [[2, 3, 2], [0, 5, -2], [0, 0, 4], [0, 0, 0]]) {
16 |
17 | }
18 |
19 | else {
20 | throw 'unit test failed for QR_test.'
21 | }
22 |
23 |
24 | //built in tolerance in hedgehog lab fixes the 0.49999 issue
25 | if (QR([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]]).Q.val === [[0.5, -0.5, 0.5, 0.5], [0.5, 0.5, -0.5, 0.5], [0.5, 0.5, 0.5, -0.5], [0.5, -0.5, -0.5, -0.5]]) {
26 |
27 | }
28 |
29 | else {
30 | throw 'unit test failed for QR_test.'
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/any_missing_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for anymissing
4 | *
5 | */
6 |
7 |
8 | function any_missing_test() {
9 |
10 | *import math: any_missing
11 |
12 | let a = [NaN, 1, 0, 0, 1];
13 | let b = mat([a, a]);
14 | let c = new Tensor([[a, a], [a, a]]);
15 |
16 | if (!(any_missing(a) === true)) {
17 | throw new Error('Unit test failed for any_missing for array');
18 | }
19 |
20 | if (!(any_missing(b) === true)) {
21 | throw new Error('Unit test failed for any_missing for matrix');
22 | }
23 |
24 | if (!(any_missing(c) === true)) {
25 | throw new Error('Unit test failed for any_missing for tensor');
26 | }
27 |
28 | //print('any_missing test pass');
29 | }
30 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/bounds_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for bounds function
4 | */
5 |
6 | function bounds_test() {
7 | *import math: bounds
8 |
9 | if (!(bounds(1, 2, 3, 4, 5) === [1, 5])) {
10 | throw new Error('Unit test failed for bounds for numbers');
11 | }
12 |
13 | let a = [1, 2, 3, 4, 5];
14 | if (!(bounds(a, 0) === [1, 5])) {
15 | throw new Error('Unit test failed for bounds for array');
16 | }
17 |
18 | let b = mat([[1, 2, 3], [4, 5, 6]]);
19 | if (!(bounds(b, 0) === [1, 6])) {
20 | throw new Error('Unit test failed for bounds for matrix');
21 | }
22 | if (!(bounds(b, 1) === mat([[1, 2, 3], [4, 5, 6]]))) {
23 | throw new Error('Unit test failed for bounds for matrix');
24 | }
25 | if (!(bounds(b, 2) === mat([[1, 3], [4, 6]]))) {
26 | throw new Error('Unit test failed for bounds for matrix');
27 | }
28 |
29 | //print('Bounds test pass');
30 | }
31 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/check_input.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jing Stone
3 | * @param input input must be a JS array
4 | * @return true if input is 2d matrix of 1d list
5 | * check the input array if it is a matrix or a vector(1d list)
6 | *
7 | */
8 |
9 | function check_input(input)
10 | {
11 | if(!Array.isArray(input)) return false;
12 |
13 | let inputLength = input.length;
14 | // empty array []
15 | if(inputLength === 0) return true;
16 | // check if it is a vector
17 | if(typeof input[0] === 'number')
18 | {
19 | for(let i = 0; i < inputLength; i++)
20 | {
21 | if(!(typeof input[i] === 'number'))
22 | {
23 | return false;
24 | }
25 | }
26 | }
27 | // check if it is a matrix
28 | else
29 | {
30 | let col = input.length;
31 | let row = input[0].length;
32 | // not allowed [[]]
33 | if(row === 0) return false;
34 | // a matrix should have the same length of column and row
35 | // while the column can not equal to row
36 | for(let i = 0; i < col; i++)
37 | {
38 | if(!Array.isArray(input[i])) return false;
39 | if(!input[i].length === row) return false;
40 | for(let j = 0; j < row; j++)
41 | {
42 | if(!(typeof input[i][j] === 'number'))
43 | {
44 | return false;
45 | }
46 | }
47 | }
48 | }
49 | return true;
50 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/check_input_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jing Stone
3 | * Unit test for check_input function
4 | */
5 |
6 | function check_input_test()
7 | {
8 | *import math: check_input
9 | let A1 = [];
10 | let A2 = [1];
11 | let A3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
12 | let A4 = [[1], [2], [3], [4]];
13 | let A5 = [[1], []];
14 | let A6 = [[]];
15 | let A7 = [1, [2], 3, 4];
16 | let A8 = [[1, 2], [2, 3], [3, 4], [[2, 2], [2, 2]]];
17 | let A9 = [[1, ], 4];
18 | let A10 = [[1], [, 2], [2]];
19 | let A11= [[1, 2, 3], [2, 3, 4], [4, 5, 6]];
20 | let A12 = [[3, 4, 5], [4, 5, 6]];
21 |
22 | function test(input, output)
23 | {
24 | if(!(check_input(input) === output))
25 | {
26 | throw new Error('Unit test failed for check_input.')
27 | }
28 | }
29 |
30 | test(A1, true);
31 | test(A2, true);
32 | test(A3, true);
33 | test(A4, true);
34 | test(A5, false);
35 | test(A6, false);
36 | test(A7, false);
37 | test(A8, false);
38 | test(A9, false);
39 | test(A10, false);
40 | test(A11, true);
41 | test(A12, true);
42 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/cholesky_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param - none
4 | * @returns - none
5 | *
6 | * Simple unit test for cholesky. Tests both JS arrays and Mat objects.
7 | */
8 |
9 |
10 | function cholesky_test() {
11 |
12 | *import math: cholesky
13 |
14 | //see if the cholesky value returns the correct results for a raw array
15 | if ((!(cholesky([[2, 1], [1, 2]]) === [[1.414, 0], [0.707, 1.225]]))) {
16 | throw new Error('Cholesky unit test has failed for raw array.');
17 | }
18 | //check for mat object
19 | if ((!(cholesky(new Mat([[2, 1], [1, 2]])) === [[1.414, 0], [0.707, 1.225]]))) {
20 | throw new Error('Cholesky unit test has failed for Mat object.');
21 | }
22 | // already throws an error within cholesky.hhs?
23 | /*if (cholesky([2,1],[0,0])... is not null?) {
24 | throw new Error('Cholesky unit test failed for symmetric check.');
25 | }*/
26 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/correcoef_test.hhs:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author Jianan Lin
3 | * test for correcoef function
4 | */
5 |
6 |
7 | function correcoef_test() {
8 |
9 | *import math: correcoef
10 |
11 | let a = [0, 1, 2, 3];
12 |
13 | if (!(correcoef(a, a) === 1)) {
14 | throw new Error('Unit test failed for correcoef for number');
15 | }
16 |
17 | //print('correcoef test pass');
18 | }
19 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/cov_test.hhs:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author Jianan Lin
3 | * test for cov function
4 | */
5 |
6 |
7 | function cov_test() {
8 |
9 | *import math: cov
10 |
11 | let a = [0, 1, 2];
12 |
13 | if (!(cov(a, a) === 1)) {
14 | throw new Error('Unit test failed for correcoef for number');
15 | }
16 |
17 | //print('cov test pass');
18 | }
19 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/cubic_equation_test:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for quadratic_equation function
4 | */
5 |
6 |
7 | function cubic_equation_test() {
8 |
9 | *import math: cubic_equation
10 |
11 | // x^3 = 0
12 | if (!(cubic_equation(1) === [0, 0, 0])) {
13 | throw new Error('Unit test for cubic_equation failed');
14 | }
15 |
16 | print("cubic_equation test pass");
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/det_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function for testing determinant of matrix
7 | */
8 |
9 | function det_test() {
10 |
11 | *import math: det
12 |
13 | if (!(det([[2, 5, 3], [7, 13, -1], [2, 3, 3]]) === -46)) {
14 | throw new Error('Failed unit test for raw array for det.');
15 | }
16 | let a = new Mat([[2, 1], [1, 2]]);
17 | if (!(det(a) === 3)) {
18 | throw new Error('Failed unit test for Mat array for det.');
19 | }
20 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/dot_multiply_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function for testing dot_divide.hhs
7 | */
8 |
9 |
10 | function dot_multiply_test() {
11 |
12 | *import math: dot_multiply
13 |
14 | let a = [1, 3, 9];
15 | let b = [9, 3, 1];
16 | if (!(dot_multiply(a, b) === mat([9, 9, 9]))) {
17 | throw new Error('Unit test failed for array for dot_multiply');
18 | }
19 |
20 | let c = mat([[1, 3, 9], [9, 3, 1]]);
21 | let d = mat([[9, 3, 1], [1, 3, 9]]);
22 | if (!(dot_multiply(d, c) === mat([[9, 9, 9], [9, 9, 9]]))) {
23 | throw new Error('Unit test failed for matrix for dot_multiply');
24 | }
25 |
26 | let e = new Tensor([[[1, 3, 9], [9, 3, 1]], [[1, 3, 9], [9, 3, 1]]]);
27 | let f = new Tensor([[[9, 3, 1], [1, 3, 9]], [[9, 3, 1], [1, 3, 9]]]);
28 | let g = dot_multiply(e, f).val;
29 | if (!(g[0] === [[9, 9, 9], [9, 9, 9]]) || !(g[1] === [[9, 9, 9], [9, 9, 9]])) {
30 | throw new Error('Unit test failed for tensor for dot_multiply');
31 | }
32 |
33 | //print('dot_multiply test pass')
34 | }
35 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/factorial_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function for testing factorial.hhs
7 | */
8 |
9 |
10 | function factorial_test() {
11 |
12 | *import math: factorial
13 |
14 | let a = 5;
15 | if (factorial(a) !== 120) {
16 | throw new Error('Unit test failed for number for factorial');
17 | }
18 |
19 | let b = [1, 2, 3];
20 | if (!(factorial(b) === [1, 2, 6])) {
21 | throw new Error('Unit test failed for array for factorial');
22 | }
23 |
24 | let c = mat([[1, 2], [3, 4]]);
25 | if (!(factorial(c) === mat([[1, 2], [6, 24]]))) {
26 | throw new Error('Unit test failed for matrix for factorial');
27 | }
28 |
29 | let d = new Tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
30 | let e = factorial(d).val;
31 | if (!(e[0] === [[1, 2], [6, 24]]) || !(e[1] === [[120, 720], [5040, 40320]])) {
32 | throw new Error('Unit test failed for tensor for factorial');
33 | }
34 |
35 | //print('factorial test pass');
36 | }
37 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/gcd_test.hhs:
--------------------------------------------------------------------------------
1 |
2 |
3 | function gcd_test() {
4 |
5 | *import math: gcd
6 |
7 | if (gcd(42, 120) !== 6) {
8 | throw new Error('Unit test failed for number for gcd');
9 | }
10 |
11 | let a = [3, 7, 9];
12 | let b = [6, 9, 12];
13 | if (!(gcd(a, b) === [3, 1, 3])) {
14 | throw new Error('Unit test failed for array for gcd');
15 | }
16 |
17 | let c = mat([[3, 7, 9], [3, 7, 9]]);
18 | let d = mat([[6, 9, 12], [6, 9, 12]]);
19 | if (!(gcd(c, d) === mat([[3, 1, 3], [3, 1, 3]]))) {
20 | throw new Error('Unit test failed for matrix for gcd');
21 | }
22 |
23 | let e = new Tensor([[[3, 7, 9], [3, 7, 9]], [[3, 7, 9], [3, 7, 9]]]);
24 | let f = new Tensor([[[6, 9, 12], [6, 9, 12]], [[6, 9, 12], [6, 9, 12]]]);
25 | let g = gcd(e, f).val;
26 | if (!(g[0] === [[3, 1, 3], [3, 1, 3]]) || !(g[1] === [[3, 1, 3], [3, 1, 3]])) {
27 | throw new Error('Unit test failed for tensor for gcd');
28 | }
29 |
30 | let h = [15, 25, 35];
31 | if (gcd(h) !== 5) {
32 | throw new Error('Unit test failed for array for gcd');
33 | }
34 |
35 | //print('gcd test pass');
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/hankel_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for hankel
4 | *
5 | */
6 |
7 |
8 |
9 | function hankel_test() {
10 |
11 | *import math: hankel
12 |
13 | let a = [1, 2, 3, 4, 5];
14 | b = hankel(a);
15 | if (!(b === mat([[1, 2, 3], [2, 3, 4], [3, 4, 5]]))) {
16 | throw new Error('Unit test failed for hankel');
17 | }
18 |
19 | let c = hankel(1, 2, 3, 4, 5);
20 | if (!(c === mat([[1, 2, 3], [2, 3, 4], [3, 4, 5]]))) {
21 | throw new Error('Unit test failed for hankel');
22 | }
23 |
24 | print('hankel test pass');
25 | }
26 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/hedgehog-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name":"math"
3 | }
4 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/identity.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Mudroad White
3 | * @param input - a positive integer denoting the size of the expected matrix.
4 | * @returns - a Mat object representing a 2D identity matrix.
5 | */
6 |
7 | function identity(input) {
8 |
9 | *import math: is_number
10 |
11 | // Corner cases for input
12 | // Argument length should be only one
13 | if ( !(arguments.length === 1) ) {
14 | throw new Error('Identity expects only one argument');
15 | }
16 | // Input should be a positive integer
17 | if (!Number.isInteger(input) || input < 0) {
18 | throw new Error('Excepted positive integer input');
19 | }
20 |
21 | // Then we return special Mat value when input is 0 or 1
22 | if (input === 0) {
23 | return new Mat([]);
24 | }
25 |
26 | if (input === 1) {
27 | return new Mat([[1]]);
28 | }
29 |
30 | // Now we can start on creating the Id matrix
31 | let result = new Mat().zeros(input, input);
32 | for (let i = 0; i < input; i++){
33 | result.val[i][i] = 1;
34 | }
35 |
36 | // return as a Mat object
37 | return result;
38 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/identity_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Mudroad White
3 | * @param
4 | * @returns
5 | *
6 | * Functions for testing the identity function.
7 | */
8 |
9 | function identity_test(){
10 | *import math: identity
11 |
12 | // Corner cases
13 | if (!(identity(0) === new Mat([]))){
14 | throw 'identity unit test failed on identity(0)';
15 | }
16 |
17 | if (!(identity(1) === new Mat([[1]]) )){
18 | throw 'identity unit test failed on identity(1)';
19 | }
20 |
21 | // Ordinary case
22 | const test1 = new Mat([[1, 0], [0, 1]]);
23 | if (!(identity(2)) === test1){
24 | throw 'identity unit test failed on identity(2)';
25 | }
26 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/is_diag_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jing Stone
3 | * Unit test for is_diag function
4 | */
5 |
6 | function is_diag_test()
7 | {
8 | *import math: is_diag
9 |
10 | let A1 = [1, 2, 3, 4];
11 | let A2 = [];
12 | let A3 = [1, 0, 0, 0];
13 | let A4 = [1, 0, 0, 1];
14 | let A5 = [[1, 0, 0], [0, 2, 0], [0, 0, 3]];
15 | let A6 = [[0, 0, 0], [0, 1, 0], [0, 0, 0]];
16 | let A7 = [[1, 0, 0], [0, 1, 0], [0, 0, 0], [0, 0, 0]];
17 | let A8 = [[1, 0, 0], [0, 1, 0], [0, 0, 3], [0, 0, 1]];
18 |
19 | function test(input, output)
20 | {
21 | if(!(is_diag(input) === output))
22 | {
23 | throw new Error('Unit test failed for is_diag.');
24 | }
25 | }
26 |
27 | test(A1, false);
28 | test(A2, true);
29 | test(A3, true);
30 | test(A4, false);
31 | test(A5, true);
32 | test(A6, true);
33 | test(A7, true);
34 | test(A8, false);
35 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/is_local_max_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for is_local_max
4 | *
5 | */
6 |
7 |
8 | function is_local_max_test() {
9 |
10 | *import math: is_local_max
11 |
12 | let a = mat([[2, 3, 1], [2, 3, 1]]);
13 | let b = mat([[0, 1, 0], [0, 1, 0]])
14 |
15 | if (!(is_local_max(a) === b)) {
16 | throw new Error('Unit test failed for is_local_max for numbers');
17 | }
18 |
19 | let c = mat([[2, 2], [3, 3], [1, 1]]);
20 | let d = mat([[0, 0], [1, 1], [0, 0]]);
21 | if (!(is_local_max(c, 1) === d)) {
22 | throw new Error('Unit test failed for is_local_max for numbers');
23 | }
24 |
25 | //print('is_local_max test pass');
26 | }
27 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/is_local_min_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for is_local_min
4 | *
5 | */
6 |
7 |
8 | function is_local_min_test() {
9 |
10 | *import math: is_local_min
11 |
12 | let a = mat([[2, 1, 3], [2, 1, 3]]);
13 | let b = mat([[0, 1, 0], [0, 1, 0]])
14 |
15 | if (!(is_local_min(a) === b)) {
16 | throw new Error('Unit test failed for is_local_min for numbers');
17 | }
18 |
19 | let c = mat([[2, 2], [1, 1], [3, 3]]);
20 | let d = mat([[0, 0], [1, 1], [0, 0]]);
21 | if (!(is_local_min(c, 1) === d)) {
22 | throw new Error('Unit test failed for is_local_min for numbers');
23 | }
24 |
25 | //print('is_local_min test pass');
26 | }
27 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/is_missing_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for ismissing
4 | *
5 | */
6 |
7 |
8 |
9 |
10 | function is_missing_test() {
11 |
12 | *import math: is_missing
13 |
14 | let a = [NaN, 1, 0, 0, 1];
15 | let b = mat([a, a]);
16 | let c = new Tensor([[a, a], [a, a]]);
17 | let d = [1, 0, 0, 0, 0];
18 |
19 | if (!(is_missing(a) === mat(d))) {
20 | throw new Error('Unit test failed for is_missing for matrix');
21 | }
22 |
23 | if (!(is_missing(b) === mat([d, d]))) {
24 | throw new Error('Unit test failed for is_missing for matrix');
25 | }
26 |
27 | let e = is_missing(c).val;
28 | if (!(e[0] === [d, d]) || !(e[1] === [d, d])) {
29 | throw new Error('Unit test failed for is_missing for tensor');
30 | }
31 |
32 | //print('is_missing test pass');
33 | }
34 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/is_number.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * Function for determining if a data type is of 'number', i.e. typical non finite number
3 | *
4 | * Original author: * is-number
5 | *
6 | * Copyright (c) 2014-present, Jon Schlinkert.
7 | * Released under the MIT License.
8 | *
9 | * @param input the value to check if its a number
10 | * @returns boolean true or false depending if its evaluated to be a number or not. Note that NaN, and infinity are not numbers
11 | */
12 |
13 | function is_number(input) {
14 |
15 | "use strict";
16 |
17 | //check if typeof input is a number first
18 | if (typeof input === 'number') {
19 | //if input-input === 0 return true; else return false;
20 | return input - input === 0;
21 | }
22 | //if we have a string for cases like '0xfff3d' and the trim is not blank
23 | if (typeof input === 'string' && !(input.trim() === '')) {
24 | //then return boolean Number.isFinite(+input) if Number.isFinite is true, if false return isFinite(+input)
25 | return Number.isFinite ? Number.isFinite(+input) : isFinite(+input)
26 | }
27 | //in all other cases return false
28 | return false;
29 | }
30 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/is_symmetric_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function that is a simple test for checking symmetricity of a matrix, raw or Mat object
7 | */
8 |
9 |
10 |
11 | function is_symmetric_test() {
12 |
13 | *import math: is_symmetric
14 |
15 | if (is_symmetric([[1, 2, 3], [1, 2, 3], [1, 2, 3]])) {
16 | throw 'is_symmetric has failed the unit test'
17 | }
18 |
19 | if (!is_symmetric([[1, 2, 3], [2, 1, 4], [3, 4, 1]])) {
20 | throw 'is_symmetric has failed the unit test'
21 | }
22 |
23 | if (!is_symmetric(new Mat([[2, 1], [1, 2]]))) {
24 | throw 'is_symmetric has failed unit test for mat obj'
25 | }
26 |
27 | if (is_symmetric(new Mat([[1, 2, 3], [1, 2, 3], [1, 2, 3]]))) {
28 | throw 'is_symmetric has failed unit test for mat obj'
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/is_tril_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function for testing the is_tril.hhs function
7 | */
8 |
9 |
10 |
11 |
12 |
13 | function is_tril_test() {
14 |
15 | *import math: is_tril
16 |
17 | let a = new Mat([[3, 0, 0], [3, 2, 0], [1, 4, 1]]);
18 | if (!is_tril(a)) {
19 | throw new Error('Unit test failed for is_tril');
20 | }
21 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/is_triu_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | *
4 | * @param
5 | * @returns
6 | *
7 | * Function for testing the is_tril.hhs function
8 | */
9 |
10 |
11 |
12 | function is_triu_test() {
13 |
14 | *import math: is_triu
15 |
16 | let a = new Mat([[3, 2, 1], [0, 1, 3], [0, 0, 2]]);
17 | if (!is_triu(a)) {
18 | throw new Error('Unit test failed for is_tril');
19 | }
20 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/lsolve_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | *
4 | * @param
5 | * @returns
6 | *
7 | * Function for unit testing lsolve (solve linear equation system with lower triangular matrix)
8 | */
9 |
10 |
11 |
12 |
13 |
14 | function lsolve_test() {
15 |
16 | *import math: lsolve
17 |
18 | let a = new Mat([[3, 0, 0], [3, 2, 0], [1, 4, 1]]);
19 | let b = [[3], [4], [5]];
20 |
21 | if (!(lsolve(a, b) === [[1], [0.5], [2]])) {
22 | throw new Error('Unit test failed for lusolve');
23 | }
24 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/lu_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function thats a unit test for the lu function/wrapper
7 | */
8 |
9 |
10 |
11 | function lu_test() {
12 |
13 | *import math: lu
14 |
15 | let a = [[1, 2], [4, 5]];
16 | if (!(lu(a).L === [[1, 0], [0.25, 1]]) ||
17 | !(lu(a).U === [[4, 5], [0, 0.75]]) ||
18 | !(lu(a).p === [[1, 0]])) {
19 | throw new Error('LU unit test failed.Note there may be multiple answers to 1 solution by different factors.');
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/lusolve_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @author Jason Reynolds
4 | * @param
5 | * @returns
6 | *
7 | * Function that's a unit test for lusolve.hhs. Tests if it gives the correct answer and if it accepts both array and Mat object
8 | */
9 |
10 |
11 |
12 | function lusolve_test() {
13 |
14 | *import math: lusolve
15 |
16 | let a = new Mat([[2, 1], [3, 4]]);
17 | let b = [[3], [3]];
18 |
19 | if (!(lusolve(a, b) === [[1.8], [-0.6]])) {
20 | throw new Error('Unit test failed for lusolve');
21 | }
22 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/mink_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jing Stone
3 | * Unit test for mink function
4 | */
5 |
6 | function mink_test()
7 | {
8 | *import math: mink
9 |
10 | let A = [[3, 2, 1, 4, 7], [2, 7, 0, 5, 2], [1, 9, 4, 3, 0], [2, 3, 4, 5, 6]];
11 | // A-num-num means the 3 parameters of mink
12 | const A_3_1 = [[1, 2, 0, 3, 0],
13 | [2, 3, 1, 4, 2],
14 | [2, 7, 4, 5, 6]];
15 | const A_3_2 = [[1, 2, 3],
16 | [0, 2, 2],
17 | [0, 1, 3],
18 | [2, 3, 4]];
19 | const A_4_1 = [[1, 2, 0, 3, 0],
20 | [2, 3, 1, 4, 2],
21 | [2, 7, 4, 5, 6],
22 | [3, 9, 4, 5, 7]];
23 | const A_4_2 = [[1, 2, 3, 4],
24 | [0, 2, 2, 5],
25 | [0, 1, 3, 4],
26 | [2, 3, 4, 5]];
27 |
28 | function test(input, k, dim, result)
29 | {
30 | let output = mink(input, k, dim);
31 | if(output instanceof Mat)
32 | {
33 | output = output.clone().val;
34 | }
35 | if(!(output.join("") === result.join("")))
36 | {
37 | throw new Error('Unit test failed for mink.')
38 | }
39 | }
40 |
41 | test(A, 3, 1, A_3_1);
42 | test(A, 3, 2, A_3_2);
43 | test(A, 4, 1, A_4_1);
44 | test(A, 4, 2, A_4_2);
45 | //print("mink test passed!");
46 | }
--------------------------------------------------------------------------------
/hedgehog-libs/math/missing_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for missing
4 | *
5 | */
6 |
7 |
8 |
9 | function missing_test() {
10 |
11 | *import math: missing
12 |
13 | let a = [1, 2, 3, NaN];
14 | let b = missing(a);
15 | // b = [1, 2, 3, NaN, NaN]
16 | if (b.val[0][4] === b.val[0][4]) {
17 | throw new Error('Unit test failed for missing');
18 | }
19 |
20 | let c = ['1', '2', '3'];
21 | let d = missing(c, 0, 2);
22 | if (!(d === mat([['1', '2', '3'], ['', '', ''], ['', '', '']]))) {
23 | throw new Error('Unit test failed for missing');
24 | }
25 |
26 | //print('missing test pass');
27 | }
28 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/ndim_test.hhs:
--------------------------------------------------------------------------------
1 | /**let a = 6;
2 | let b = [5,34,3];
3 | let c = [[3,2,3],[3,4,2]];
4 | let d = new Mat([3,4,2]);
5 | let e = new Mat([[3,4],[4,3],[4,3]])
6 | let f = [[[2,2],[3,3],[4,4]],[[2,2],[3,3],[4,4]],[[4,4],[3,3],[2,2]]]
7 | let g = new Tensor([[[2,2],[3,3],[4,4]],[[2,2],[3,3],[4,4]],[[4,4],[3,3],[2,2]]]);**/
8 |
9 | //its taking e,f,g and saying 2.... but if i enter 3 values in each sub array it says 3. something weird with the dimensions
10 | //will think about it tomorrow
--------------------------------------------------------------------------------
/hedgehog-libs/math/normalize_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for normalize
4 | *
5 | */
6 |
7 |
8 | function normalize_test() {
9 |
10 | *import math: normalize
11 |
12 | if (!(normalize(1, 2, 3) === [0, 0.5, 1])) {
13 | throw new Error('Unit test failed for normalize for numbers');
14 | }
15 |
16 | let a = [[1, 2, 3]];
17 | let b = mat(a);
18 | let c = new Tensor([a, a]);
19 |
20 | if (!(normalize(a) === mat([[0, 0.5, 1]]))) {
21 | throw new Error('Unit test failed for normalize for array');
22 | }
23 |
24 | if (!(normalize(b) === mat([[0, 0.5, 1]]))) {
25 | throw new Error('Unit test failed for normalize for matrix');
26 | }
27 |
28 | let d = normalize(c).val
29 | if (!(d[0] === [[0, 0.5, 1]]) || !(d[1] === [[0, 0.5, 1]])) {
30 | throw new Error('Unit test failed for normalize for tensor');
31 | }
32 |
33 | //print('normalize test pass');
34 | }
35 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/pascal.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Alan Liang
3 | * @param n - integer, size of final matrix
4 | * @returns - Mat object matrix
5 | *
6 | * a symmetric Pascal matrix contains the binomial coefficients as its elements.
7 | *
8 | */
9 |
10 | function pascal(n)
11 | {
12 | // wrong argument number
13 | if (arguments.length === 0) {
14 | throw new Error('Exception occurred in pascal - no argument given');
15 | }
16 | else if (arguments.length > 1) {
17 | throw new Error('Exception occurred in pascal - wrong argument number');
18 | }
19 | // the input shoule be an integer
20 | if(!Number.isInteger(n)) {
21 | throw new Error("Exception occurred in pascal - the parameter must be an integer.");
22 | }
23 |
24 | let pascalSquare = Array(n).fill(0).map(x => Array(n).fill(0));
25 |
26 | // Fill the first row with 1s
27 | pascalSquare[0] = Array(n).fill(1);
28 |
29 | // Fill the first column with 1s
30 | for (let row = 0; row < n; row++) {
31 | pascalSquare[row][0] = 1;
32 | }
33 |
34 | // Use the definition of pascal matrix
35 | for (let row = 1; row < n; row++) {
36 | for (let col = 1; col < n; col++) {
37 | pascalSquare[row][col] = pascalSquare[row-1][col] + pascalSquare[row][col-1];
38 | }
39 | }
40 | return pascalSquare;
41 | }
42 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/pascal_test.hhs:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author Alan Liang
3 | * test for pascal matrix generation
4 | */
5 |
6 |
7 | function pascal_test() {
8 |
9 | *import math: pascal
10 | *import math: inv
11 |
12 | // Property of pascal(n) : entries of pascal(n)^-1 are integers
13 | for (let n = 1; n < 5; n++) {
14 | let A = pascal(n);
15 | if (inv(A).val.some(c => c.some(x => !isInteger(x)))) {
16 | throw new Error('Unit test failed for pascal');
17 | }
18 | }
19 |
20 | function isInteger(x) {
21 | return Number.isInteger(Math.round(x * 100000) / 100000);
22 | }
23 |
24 | //print('pascal test pass');
25 | }
26 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/percentile_test.hhs:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author Jianan Lin
3 | * test for percentile function
4 | */
5 |
6 |
7 | function percentile_test() {
8 |
9 | *import math: percentile
10 |
11 | let a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
12 |
13 | if (!(percentile(a, 0) === [1])) {
14 | throw new Error('Unit test failed for quantile');
15 | }
16 |
17 | if (!(percentile(a, 100) === a)) {
18 | throw new Error('Unit test failed for quantile');
19 | }
20 |
21 | if (!(percentile(a, 50) === [1, 2, 3, 4, 5])) {
22 | throw new Error('Unit test failed for quantile');
23 | }
24 |
25 | if (!(percentile(a, 30) === [1, 2, 3])) {
26 | throw new Error('Unit test failed for quantile');
27 | }
28 |
29 | //print('percentile test pass');
30 | }
31 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/quantile_test.hhs:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author Jianan Lin
3 | * test for quantile function
4 | */
5 |
6 |
7 | function quantile_test() {
8 |
9 | *import math: quantile
10 |
11 | let a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
12 |
13 | if (!(quantile(a, 0) === [1])) {
14 | throw new Error('Unit test failed for quantile');
15 | }
16 |
17 | if (!(quantile(a, 1) === a)) {
18 | throw new Error('Unit test failed for quantile');
19 | }
20 |
21 | if (!(quantile(a, 0.5) === [1, 2, 3, 4, 5])) {
22 | throw new Error('Unit test failed for quantile');
23 | }
24 |
25 | if (!(quantile(a, 0.3) === [1, 2, 3])) {
26 | throw new Error('Unit test failed for quantile');
27 | }
28 |
29 | //print('quantile test pass');
30 | }
31 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/quartic_equation_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @Author Jianan Lin (林家南)
3 | * test function for quartic_equation
4 | */
5 |
6 |
7 |
8 | function quartic_equation_test() {
9 |
10 | *import math: quartic_equation
11 |
12 | if (!(quartic_equation(3, 6, -123, -126, 1080) === [-4, 3, -6, 5])) {
13 | throw new Error('quartic_equation test failed');
14 | }
15 |
16 | //print('quartic_equation test pass');
17 | }
18 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/reshape_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin (林家南)
3 | * Function of test unit for reshape
4 | */
5 |
6 | function reshape_test() {
7 |
8 | *import math: reshape
9 |
10 | let a = [1, 2, 3, 4, 5, 6, 7, 8];
11 | let b = reshape(a, [2, 2, 2]).val;
12 | for (let i = 0; i < 2; i++) {
13 | for (let j = 0; j < 2; j++) {
14 | for (let k = 0; k < 2; k++) {
15 | if (b[i][j][k] !== 4 * i + 2 * j + k + 1) {
16 | throw new Error('Failed unit test for reshape.');
17 | }
18 | }
19 | }
20 | }
21 |
22 | let c = reshape(a, [2, -1]).val;
23 | for (let i = 0; i < 2; i++) {
24 | for (let j = 0; j < 4; j++) {
25 | if (c[i][j] !== 4 * i + j + 1) {
26 | throw new Error('Failed unit test for reshape.');
27 | }
28 | }
29 | }
30 |
31 | //print('reshape test pass');
32 | }
33 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/rmmissing_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for ismissing
4 | *
5 | */
6 |
7 |
8 |
9 | function rmmissing_test() {
10 |
11 | *import math: rmmissing
12 |
13 | let a = [1, 2, NaN];
14 | let b = rmmissing(a);
15 |
16 | if (!(b === mat([1, 2]))) {
17 | throw new Error('Unit test failed for rmmissing_test');
18 | }
19 |
20 | let c = [[1], [2], [NaN]];
21 | let d = rmmissing(c);
22 | if (!(d === mat([[1], [2]]))) {
23 | throw new Error('Unit test failed for rmmissing_test');
24 | }
25 |
26 | let e = mat([[1, 2, 3], [NaN, null, 4]]);
27 | let f = rmmissing(e, 0);
28 | if (!(f === mat([[3], [4]]))) {
29 | throw new Error('Unit test failed for rmmissing_test');
30 | }
31 |
32 | let g = mat([[1, NaN], [2, null], [3, 4]]);
33 | let h = rmmissing(g, 1);
34 | if (!(h === mat([[3, 4]]))) {
35 | throw new Error('Unit test failed for rmmissing_test');
36 | }
37 |
38 | //print('rmmissing test pass');
39 | }
40 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/rms_test.hhs:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author Jianan Lin
3 | * test for rms function
4 | */
5 |
6 |
7 | function rms_test() {
8 |
9 | *import math: rms
10 |
11 | let a = [1, 1, 1, 1, 1];
12 |
13 | if (!(rms(1, 1, 1) === 1)) {
14 | throw new Error('Unit test failed for rms for number');
15 | }
16 |
17 | if (!(rms(a) === 1)) {
18 | throw new Error('Unit test failed for rms for array');
19 | }
20 |
21 | //print('rms test pass');
22 | }
23 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/smooth_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for smooth
4 | *
5 | */
6 |
7 |
8 | function smooth_test() {
9 |
10 | *import math: smooth
11 |
12 | let a = mat([[0, 2, 1, 2, 0], [0, 2, 1, 2, 0]]);
13 | let b = mat([[0, 1, 1, 1, 0], [0, 1, 1, 1, 0]]);
14 |
15 | if (!(smooth(a) === b)) {
16 | throw new Error('Unit test failed for smooth for numbers');
17 | }
18 |
19 | let c = mat([[0, 0], [2, 2], [1, 1], [2, 2], [0, 0]]);
20 | let d = mat([[0, 0], [1, 1], [1, 1], [1, 1], [0, 0]]);
21 | if (!(smooth(c, 1) === d)) {
22 | throw new Error('Unit test failed for smooth for numbers');
23 | }
24 |
25 | //print('smooth test pass');
26 | }
27 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/standard_missing_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jianan Lin
3 | * Unit test for standard_missing
4 | *
5 | */
6 |
7 |
8 |
9 | function standard_missing_test() {
10 |
11 | *import math: standard_missing
12 |
13 | let a = [1, 2, 3, 4, 5];
14 | let b = standard_missing(a, [1, 2]);
15 | if (b.val[0][0] === b.val[0][0]) {
16 | throw new Error('Unit test failed for standard_missing');
17 | }
18 |
19 | let c = mat([[1, 2, 3], [4, 5, 6]]);
20 | let d = standard_missing(c, 1);
21 | if (d.val[0][0] === d.val[0][0]) {
22 | throw new Error('Unit test failed for standard_missing');
23 | }
24 |
25 | let e = standard_missing(c, [1, 2]);
26 | if (e.val[0][0] === e.val[0][0]) {
27 | throw new Error('Unit test failed for standard_missing');
28 | }
29 | print('standard_missing test pass');
30 | }
31 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/trace_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function unit test for trace, determines if it's adding up the diagonal entries correctly
7 | */
8 |
9 |
10 |
11 |
12 | function trace_test() {
13 |
14 | *import math: trace
15 |
16 | if (!(trace([[2.1, 3], [3, 6.11]]) === 8.21)) {
17 | throw "Trace unit test has failed."
18 | }
19 |
20 | //check for boundaries? no done in trace
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/usolve_test.hhs:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Jason Reynolds
3 | * @param
4 | * @returns
5 | *
6 | * Function unit test for usolve - solves upper triangular matrix Ax=b cases
7 | *
8 | */
9 |
10 |
11 |
12 | function usolve_test() {
13 |
14 | *import math: usolve
15 |
16 | let a = new Mat([[3, 2, 1], [0, 1, 3], [0, 0, 2]]);
17 | let b = new Mat([[3], [4], [5]]);
18 | if (!(usolve(a, b) === mat([[2.5], [-3.5], [2.5]]))) {
19 | throw new Error('Unit test failed for usolve_test')
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/hedgehog-libs/math/vander_test.hhs:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author Jianan Lin
3 | * test for iqr function
4 | */
5 |
6 | function vander_test() {
7 |
8 | *import math: vander
9 |
10 | if (!(vander([1, 2], 2) === mat([[1, 1, 1], [1, 2, 4]]))) {
11 | throw new Error('Unit test failed for vander');
12 | }
13 |
14 | print('vander test pass');
15 | }
16 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "packages": ["packages/*"],
3 | "npmClient": "yarn",
4 | "useWorkspaces": true,
5 | "version": "0.0.0"
6 | }
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@hedgehogcomputing/root",
3 | "private": true,
4 | "version": "0.0.0",
5 | "license": "Apache-2.0",
6 | "workspaces": [
7 | "packages/*"
8 | ],
9 | "devDependencies": {
10 | "lerna": "^6.0.1",
11 | "patch-package": "^6.4.7",
12 | "typescript": "^3.9.7"
13 | },
14 | "scripts": {
15 | "init": "lerna add @hedgehogcomputing/core --scope @hedgehogcomputing/lab --scope @hedgehogcomputing/canvas",
16 | "dev:web": "lerna exec --scope @hedgehogcomputing/lab yarn start",
17 | "build:core": "lerna exec --scope @hedgehogcomputing/core yarn build",
18 | "watch": "lerna run --parallel watch",
19 | "build": "lerna run build --stream",
20 | "postinstall": "patch-package",
21 | "vercel-build": "yarn global add gl node-gyp-build node-gyp"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/README.md:
--------------------------------------------------------------------------------
1 | # hedgehog Canvas Components
2 |
3 | This package can be used to render the output of the hedgehog compiler result easily.
4 |
5 | ## Installation
6 |
7 | ```bash
8 | yarn install @hedgehogcomputing/canvas
9 | # or
10 | npm install @hedgehogcomputing/canvas
11 | ```
12 |
13 | ## Usage
14 |
15 | > `outputItem` is the output of the hedgehog compiler(hedgehog-core)
16 |
17 | ```jsx
18 | import Output from "@hedgehogcomputing/canvas/src/Output";
19 |
20 | const Results = () => {
21 | return (
22 | <>
23 |
24 | >
25 | )
26 | }
27 | ```
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@hedgehogcomputing/canvas",
3 | "version": "0.7.0",
4 | "license": "Apache-2.0",
5 | "dependencies": {
6 | "@hedgehogcomputing/core": "^0.7.0",
7 | "@testing-library/jest-dom": "^5.16.5",
8 | "@testing-library/react": "^13.4.0",
9 | "@testing-library/user-event": "^13.5.0",
10 | "@types/jest": "^27.5.2",
11 | "@types/node": "^16.11.62",
12 | "@types/react": "^18.0.21",
13 | "@types/react-dom": "^18.0.6",
14 | "react": "^18.2.0",
15 | "react-dom": "^18.2.0",
16 | "react-scripts": "3.4.1",
17 | "typescript": "^3.9.7",
18 | "web-vitals": "^2.1.4"
19 | },
20 | "scripts": {
21 | "start": "react-scripts start",
22 | "build": "react-scripts build",
23 | "test": "react-scripts test",
24 | "eject": "react-scripts eject"
25 | },
26 | "eslintConfig": {
27 | "extends": [
28 | "react-app",
29 | "react-app/jest"
30 | ]
31 | },
32 | "browserslist": {
33 | "production": [
34 | ">0.2%",
35 | "not dead",
36 | "not op_mini all"
37 | ],
38 | "development": [
39 | "last 1 chrome version",
40 | "last 1 firefox version",
41 | "last 1 safari version"
42 | ]
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-canvas/public/favicon.ico
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-canvas/public/logo192.png
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-canvas/public/logo512.png
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/App.test.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { render, screen } from '@testing-library/react';
3 | import App from './App';
4 |
5 | test('renders learn react link', () => {
6 | render( );
7 | const linkElement = screen.getByText(/learn react/i);
8 | expect(linkElement).toBeInTheDocument();
9 | });
10 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/App.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import logo from './logo.svg';
3 | import './App.css';
4 |
5 | function App() {
6 | return (
7 |
23 | );
24 | }
25 |
26 | export default App;
27 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/Output/index.ts:
--------------------------------------------------------------------------------
1 | import Output from './Output';
2 |
3 | export default Output;
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | const root = ReactDOM.createRoot(
8 | document.getElementById('root') as HTMLElement
9 | );
10 | root.render(
11 |
12 |
13 |
14 | );
15 |
16 | // If you want to start measuring performance in your app, pass a function
17 | // to log results (for example: reportWebVitals(console.log))
18 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
19 | reportWebVitals();
20 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/reportWebVitals.ts:
--------------------------------------------------------------------------------
1 | import { ReportHandler } from 'web-vitals';
2 |
3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => {
4 | if (onPerfEntry && onPerfEntry instanceof Function) {
5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
6 | getCLS(onPerfEntry);
7 | getFID(onPerfEntry);
8 | getFCP(onPerfEntry);
9 | getLCP(onPerfEntry);
10 | getTTFB(onPerfEntry);
11 | });
12 | }
13 | };
14 |
15 | export default reportWebVitals;
16 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/src/setupTests.ts:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/packages/hedgehog-canvas/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "noFallthroughCasesInSwitch": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "jsx": "react"
22 | },
23 | "include": [
24 | "src"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": ["prettier", "@typescript-eslint"],
3 | "parser": "@typescript-eslint/parser",
4 | "extends": [
5 | "plugin:@typescript-eslint/recommended"
6 | ],
7 | "rules": {
8 | "prettier/prettier": [
9 | "error",
10 | {
11 | "printWidth": 100,
12 | "tabWidth": 2,
13 | "semi": true,
14 | "trailingComma": "none",
15 | "singleQuote": true,
16 | "bracketSpacing": true,
17 | "jsxBracketSameLine": true,
18 | "alwaysParens":"avoid",
19 | "@typescript-eslint/ban-ts-ignore": "off",
20 | "endOfLine": "auto"
21 | }
22 | ]
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/index.ts:
--------------------------------------------------------------------------------
1 | import { executeOutput } from './runtime';
2 | import transpile from './transpiler/transpiler-core';
3 |
4 | export * from './output/output-item';
5 | export * from './lib/table';
6 |
7 | export { executeOutput, transpile };
8 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/runtime/globalConfigVars.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | export const DEFAULT_DIGITS = 5;
3 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/runtime/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the core runtime for compiled hedgehog script,
3 | * all the built-in functions and classes must be defined in prelude
4 | * to make sure that user can call it at function executeOutput()
5 | */
6 |
7 | import * as prelude from './prelude';
8 | import * as vars from './vars';
9 |
10 | export function executeOutput(code: string) {
11 | let preludeImport = '';
12 | for (const key in prelude) {
13 | preludeImport += `const ${key} = prelude.${key};`;
14 | }
15 | for (const key in vars) {
16 | preludeImport += `var ${key} = vars.${key};`;
17 | }
18 |
19 | // eslint-disable-next-line no-new-func
20 | // eslint-disable-next-line prettier/prettier
21 | const fn = new Function( 'prelude', 'vars', preludeImport + code + '\n return _OUTPUT_ITEMS_LIST_;');
22 |
23 | const results = fn.call({}, prelude, vars);
24 |
25 | console.log('***Execution results***');
26 | console.log(results);
27 | console.log('***End of execution results***');
28 |
29 | const returnList = [...results];
30 | prelude._OUTPUT_ITEMS_LIST_.length = 0;
31 | return returnList;
32 | }
33 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/runtime/vars.ts:
--------------------------------------------------------------------------------
1 | export const AUTHENTICATION = '';
2 | export const BASE_URL = '';
3 | export const MODE = 'RELEASE';
4 | export const USERNAME = '';
5 | export const PASSWORD = '';
6 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/transpiler/CodeSnippetObject.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Each code snippet contains a type annotation,
3 | and the type annotation is used to determine
4 | the type of the code snippet.
5 |
6 | If the type annotation is js, the code snippet
7 | will be kept as is, and will be executed as is.
8 |
9 | If the type annotation is hhs, the code snippet
10 | will be transformed into javascript before executed.
11 | */
12 |
13 | export enum CodeSnippetType {
14 | js = 1,
15 | hhs = 2
16 | }
17 |
18 | export class CodeSnippet {
19 | type: CodeSnippetType;
20 | code: string;
21 | constructor(type: CodeSnippetType, code: string) {
22 | this.type = type;
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/transpiler/FetchURL/fetchApi.ts:
--------------------------------------------------------------------------------
1 | const fetchApi = (username: string, filename: string): Promise => {
2 | const host = location.hostname;
3 | let apiHost;
4 | switch (host) {
5 | case "preview.hlab.app":
6 | apiHost = "https://api.preview.hlab.app";
7 | break;
8 | case "hlab.app":
9 | apiHost = "https://api.hlab.app";
10 | break;
11 | default:
12 | apiHost = "http://localhost:9000";
13 | }
14 |
15 | const api = apiHost + '/snippets?user=' + username + '&title=' + filename;
16 | return fetch(api, { method: 'get' }).then(res => res.json()).then((data) => {
17 | const returnResponseStatusCode = data.statusCode;
18 | if (returnResponseStatusCode !== 200) {
19 | throw 'Cannot fetch the file: ' + filename + ' from user: ' + username + ' , status code: ' + returnResponseStatusCode;
20 | }
21 | const real_library = data.response.result.content;
22 | return real_library;
23 | });
24 | };
25 |
26 | export { fetchApi };
27 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/transpiler/FetchURL/fetchURL.ts:
--------------------------------------------------------------------------------
1 | const fetchURL = (url: string): Promise => {
2 | return fetch(url, { method: 'get' }).then((body) => {
3 | const returnResponseStatusCode = body.status;
4 | if (returnResponseStatusCode !== 200) {
5 | throw 'Cannot fetch the URL: ' + url + ' , status code: ' + returnResponseStatusCode;
6 | }
7 | const real_library = body.text();
8 | return real_library;
9 | });
10 | };
11 |
12 | export { fetchURL };
13 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/transpiler/GithubDependency/githubDependency.ts:
--------------------------------------------------------------------------------
1 | import { fetchURL } from '../FetchURL/fetchURL';
2 |
3 | // This is the base URL for the GitHub user content API.
4 | // It is used to fetch the content of the library from GitHub.
5 | // For example, user wants to import a library from
6 | // https://raw.githubusercontent.com/Hedgehog-Computing/math/main/QR.hhs
7 | // Then, the user only needs to import as:
8 | // github: Hedgehog-Computing/math/main/QR
9 | // And hedgehog lab will compose the full URL as:
10 | // GithubRawUserContentBaseUrl + 'Hedgehog-Computing/math/main/QR' + '.hhs'
11 | const GithubRawUserContentBaseUrl = 'https://raw.githubusercontent.com/';
12 |
13 | // Generate the full URL for the library and fetch from GitHub.
14 | async function githubDependency(githubPackagePath: string): Promise {
15 | const fullPath = GithubRawUserContentBaseUrl + githubPackagePath.trim() + '.hhs';
16 | const real_library = await fetchURL(fullPath);
17 | return real_library;
18 | }
19 |
20 | export { githubDependency };
21 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/src/utilites/fetch-library.ts:
--------------------------------------------------------------------------------
1 | function fetchLibrary(lib_url: string) {
2 | const raw_string_return = fetch(lib_url, { method: 'get' })
3 | .then(function (body) {
4 | return body.text();
5 | })
6 | .then(function (data) {
7 | //console.log('Fetch return raw string: \n' + data);
8 | return data;
9 | });
10 |
11 | return raw_string_return;
12 | }
13 |
14 | export default fetchLibrary;
15 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/test/basicTest/test.ts:
--------------------------------------------------------------------------------
1 | import { assert } from 'chai';
2 | import { transpile, executeOutput } from '../../src/index';
3 |
4 | describe('The basic compiler and runtime test', async () => {
5 | const transpileResult = await transpile('x = 1; print(x);');
6 | const executeResult = await executeOutput(transpileResult);
7 | it('should pass', () => {
8 | assert.equal(executeResult.length, 1);
9 | assert.equal(executeResult[0].text, '1');
10 | assert.equal(executeResult[0].itemType, 'TEXT');
11 | });
12 | });
13 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/test/js-embedded-test/simpleTest.ts:
--------------------------------------------------------------------------------
1 | import { assert } from 'chai';
2 | import { transpile, executeOutput } from '../../src/index';
3 | import { isEqual } from 'lodash';
4 |
5 | const testCode1 = `
6 | let a = 1;
7 | let b = 2;
8 | let c = 3;
9 | let matrix1 = [[1,2],[3,4]];
10 | let matrix2 = matrix1 * 2;
11 | js_start
12 | let d = a + 1;
13 | let e = b + 1;
14 | let f = c + 1;
15 | js_end
16 | print( d===2 );
17 | print( e===3 );
18 | print( f===4 );
19 | print( 'Hello World' );
20 | print( matrix2 === [[2,4],[6,8]] );
21 | `;
22 |
23 | describe('The embedded-js simple test 1', async () => {
24 | it('should pass', async () => {
25 | const transpileResult = await transpile(testCode1);
26 | const executeResult = executeOutput(transpileResult);
27 | assert.equal(executeResult[0].text, 'true');
28 | assert.equal(executeResult[1].text, 'true');
29 | assert.equal(executeResult[2].text, 'true');
30 | assert.equal(executeResult[3].text, 'Hello World');
31 | assert.equal(executeResult[4].text, 'true');
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/test/matrixTest/matrixOperatorTest.ts:
--------------------------------------------------------------------------------
1 | import { assert } from 'chai';
2 | import { transpile, executeOutput } from '../../src/index';
3 |
4 | describe('Matrix operator test', async () => {
5 | it('should pass', async () => {
6 | const matrixPlusCode = `
7 | let a = [[1,2],[3,4]];
8 | let b = [[5,6],[7,8]];
9 | let c = a + b;
10 | print( c ==[ [ 6, 8 ], [ 10, 12 ] ] );
11 | `;
12 | const transpileResult = await transpile(matrixPlusCode);
13 | const executeResult = await executeOutput(transpileResult);
14 | assert.equal(executeResult.length, 1);
15 | assert.equal(executeResult[0].text, 'true');
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/test/test.ts:
--------------------------------------------------------------------------------
1 | import { assert } from 'chai';
2 |
3 | describe('The fundamental test', () => {
4 | it('should pass', () => {
5 | assert.equal(true, true);
6 | });
7 | });
8 |
--------------------------------------------------------------------------------
/packages/hedgehog-core/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["src"],
3 | "extends": "../../tsconfig.json",
4 | "compilerOptions": {
5 | "outDir": "dist",
6 | "rootDir": "src"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": ["@typescript-eslint"],
3 | "parser": "@typescript-eslint/parser",
4 | "extends": [
5 | "plugin:react/recommended",
6 | "plugin:@typescript-eslint/recommended",
7 | "plugin:react-hooks/recommended"
8 | ],
9 | "rules": {
10 | "no-unused-vars": "off",
11 | "@typescript-eslint/no-unused-vars": ["off"],
12 | "@typescript-eslint/no-use-before-define": "off",
13 | "@typescript-eslint/no-explicit-any": "off",
14 | "@typescript-eslint/explicit-module-boundary-types": "off",
15 | "@typescript-eslint/ban-ts-comment": "off"
16 | },
17 | "settings": {
18 | "react": {
19 | "pragma": "React",
20 | "version": "detect"
21 | }
22 | },
23 | "parserOptions": {
24 | "ecmaVersion": 2019,
25 | "sourceType": "module",
26 | "ecmaFeatures": {
27 | "jsx": true
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@hedgehogcomputing/lab",
3 | "version": "0.7.0",
4 | "license": "Apache-2.0",
5 | "dependencies": {
6 | "@hedgehogcomputing/core": "^0.7.0",
7 | "@testing-library/jest-dom": "^5.16.5",
8 | "@testing-library/react": "^13.4.0",
9 | "@testing-library/user-event": "^13.5.0",
10 | "@types/jest": "^27.5.2",
11 | "@types/node": "^16.11.62",
12 | "@types/react": "^18.0.21",
13 | "@types/react-dom": "^18.0.6",
14 | "react": "^18.2.0",
15 | "react-dom": "^18.2.0",
16 | "react-scripts": "3.4.1",
17 | "typescript": "^3.9.7",
18 | "web-vitals": "^2.1.4"
19 | },
20 | "scripts": {
21 | "start": "react-scripts start",
22 | "build": "react-scripts build",
23 | "test": "react-scripts test",
24 | "eject": "react-scripts eject"
25 | },
26 | "eslintConfig": {
27 | "extends": [
28 | "react-app",
29 | "react-app/jest"
30 | ]
31 | },
32 | "browserslist": {
33 | "production": [
34 | ">0.2%",
35 | "not dead",
36 | "not op_mini all"
37 | ],
38 | "development": [
39 | "last 1 chrome version",
40 | "last 1 firefox version",
41 | "last 1 safari version"
42 | ]
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/public/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-lab/public/cat.png
--------------------------------------------------------------------------------
/packages/hedgehog-lab/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-lab/public/favicon.ico
--------------------------------------------------------------------------------
/packages/hedgehog-lab/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-lab/public/logo192.png
--------------------------------------------------------------------------------
/packages/hedgehog-lab/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-lab/public/logo512.png
--------------------------------------------------------------------------------
/packages/hedgehog-lab/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Hedgehog Lab",
4 | "icons": [
5 | {
6 | "src": "cat.png",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "cat.png",
12 | "type": "image/png",
13 | "sizes": "192x192",
14 | "purpose": "maskable any"
15 | },
16 | {
17 | "src": "cat.png",
18 | "type": "image/png",
19 | "sizes": "512x512"
20 | }
21 | ],
22 | "start_url": ".",
23 | "display": "standalone",
24 | "theme_color": "#000000",
25 | "background_color": "#ffffff"
26 | }
27 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/readme.md:
--------------------------------------------------------------------------------
1 | # Hedgehog Lab package
2 |
3 | This package provides a simple way to run Hedgehog editor in your application.
4 |
5 | ## Installation
6 |
7 | ```bash
8 | yarn install @hedgehogcomputing/lab
9 | # or
10 | npm install @hedgehogcomputing/lab
11 | ```
12 |
13 | ## Usage
14 |
15 | ```jsx
16 | import HedgehogLab from "@hedgehogcomputing/lab/src/HedgehogLab";
17 |
18 | const Draft = () => {
19 | const yourSource = "any string"
20 | return (
21 | <>
22 |
23 |
24 | >
25 | )
26 | }
27 | ```
28 |
29 | ## API
30 | ` ` accepts the following props:
31 |
32 | -- alternative
33 | * source: `string` - the source code to be displayed in the editor
34 | * userSnippet : `string`- the user snippet to be displayed in the editor, example: "@username/snippet"
35 |
36 | -- common
37 | * defaultFullScreen: `boolean` - whether the editor should be displayed in full screen mode by default
38 | * defaultLiveMode: `boolean` - whether the compiler should be auto-reload in live mode by default
--------------------------------------------------------------------------------
/packages/hedgehog-lab/src/App.css:
--------------------------------------------------------------------------------
1 | .view-lines {
2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
3 | Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
4 | }
5 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/src/App.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | const App = (): React.ReactElement => {
4 | return (
5 |
6 |
7 | );
8 | };
9 |
10 | export default App;
11 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/src/HedgehogLab.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import SnippetEditor, {ISnippetEditor} from "@hedgehogcomputing/website/src/pages/Snippets/Editor";
3 |
4 | const HedgehogLab: React.FC = (props) => {
5 | return (
6 |
7 | )
8 | }
9 |
10 | export default HedgehogLab;
--------------------------------------------------------------------------------
/packages/hedgehog-lab/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import './index.css';
3 | import App from './App';
4 | import {createRoot} from "react-dom/client";
5 |
6 | const container = document.getElementById('root');
7 | // @ts-ignore
8 | const root = createRoot(container);
9 |
10 | root.render( )
11 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.worker.ts' {
4 | class WebpackWorker extends Worker {
5 | constructor();
6 | }
7 |
8 | export default WebpackWorker;
9 | }
10 |
--------------------------------------------------------------------------------
/packages/hedgehog-lab/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "esModuleInterop": true,
8 | "allowSyntheticDefaultImports": true,
9 | "strict": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "noEmit": true,
16 | "jsx": "react"
17 | },
18 | "include": ["src"]
19 | }
20 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": ["@typescript-eslint"],
3 | "parser": "@typescript-eslint/parser",
4 | "extends": [
5 | "plugin:react/recommended",
6 | "plugin:@typescript-eslint/recommended",
7 | "plugin:react-hooks/recommended"
8 | ],
9 | "rules": {
10 | "no-unused-vars": "off",
11 | "@typescript-eslint/no-unused-vars": ["off"],
12 | "@typescript-eslint/no-use-before-define": "off",
13 | "@typescript-eslint/no-explicit-any": "off",
14 | "@typescript-eslint/explicit-module-boundary-types": "off",
15 | "@typescript-eslint/ban-ts-comment": "off"
16 | },
17 | "settings": {
18 | "react": {
19 | "pragma": "React",
20 | "version": "detect"
21 | }
22 | },
23 | "parserOptions": {
24 | "ecmaVersion": 2019,
25 | "sourceType": "module",
26 | "ecmaFeatures": {
27 | "jsx": true
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/public/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-website/public/cat.png
--------------------------------------------------------------------------------
/packages/hedgehog-website/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-website/public/favicon.ico
--------------------------------------------------------------------------------
/packages/hedgehog-website/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-website/public/logo192.png
--------------------------------------------------------------------------------
/packages/hedgehog-website/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hedgehog-Computing/hedgehog-lab/4d33ccc93e4b55c5b2c8edb5072c4c1784d086cf/packages/hedgehog-website/public/logo512.png
--------------------------------------------------------------------------------
/packages/hedgehog-website/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "HLAB",
3 | "name": "Hedgehog Lab",
4 | "icons": [
5 | {
6 | "src": "cat.png",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "cat.png",
12 | "type": "image/png",
13 | "sizes": "192x192",
14 | "purpose": "maskable any"
15 | },
16 | {
17 | "src": "cat.png",
18 | "type": "image/png",
19 | "sizes": "512x512"
20 | }
21 | ],
22 | "start_url": ".",
23 | "display": "standalone",
24 | "theme_color": "#000000",
25 | "background_color": "#ffffff"
26 | }
27 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/App.css:
--------------------------------------------------------------------------------
1 | .view-lines {
2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
3 | Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
4 | }
5 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/compiler.worker.ts:
--------------------------------------------------------------------------------
1 | import * as Comlink from 'comlink';
2 | import { transpile } from '@hedgehogcomputing/core';
3 |
4 | const compilerWorker = {
5 | compile: (e: any) => transpile(e)
6 | };
7 |
8 | Comlink.expose(compilerWorker);
9 |
10 | export default null as any;
11 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Base/Editor/Loading.tsx:
--------------------------------------------------------------------------------
1 | import {Box, Skeleton} from "@mui/material";
2 | import React from "react";
3 |
4 | const EditorLoading = () => {
5 | return (
6 |
7 | {Array.from([1, 2, 3, 4, 5]).map((_, index) => (
8 |
9 | ))}
10 |
11 | )
12 | }
13 |
14 | export default EditorLoading
15 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Base/Input/Description/UserDescriptionInput.tsx:
--------------------------------------------------------------------------------
1 | import {Controller, useFormContext} from "react-hook-form";
2 | import * as React from "react";
3 | import {BaseTextFieldProps} from "@mui/material";
4 | import BaseOutlinedInput from "../BaseOutlinedInput/BaseOutlinedInput";
5 | import {PersonOutlined} from "@mui/icons-material";
6 |
7 | const name = 'description';
8 |
9 | const UserDescriptionInput: React.FC = (props) => {
10 | const useFormMethods = useFormContext()
11 |
12 | return (
13 |
18 |
24 | }}
25 | />
26 | }
27 | />
28 | )
29 | }
30 |
31 | export default UserDescriptionInput;
32 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Base/Input/Email/EmailInput.tsx:
--------------------------------------------------------------------------------
1 | import {Controller, useFormContext} from "react-hook-form";
2 | import * as React from "react";
3 | import BaseOutlinedInput from "../BaseOutlinedInput/BaseOutlinedInput";
4 | import {EmailOutlined} from "@mui/icons-material";
5 | import {IInputProps} from "../../../../interfaces/IFormInput";
6 |
7 | const name = 'email'
8 |
9 | const EmailInput: React.FC = (props): React.ReactElement => {
10 | const useFormMethods = useFormContext()
11 |
12 | return (
13 |
18 | }}/>
23 | }
24 | />
25 | )
26 | }
27 |
28 |
29 | export default EmailInput
30 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Base/Input/Snippet/Description/SnippetDescriptionInput.tsx:
--------------------------------------------------------------------------------
1 | import {Controller, useFormContext} from "react-hook-form";
2 | import BaseOutlinedInput from "../../BaseOutlinedInput/BaseOutlinedInput";
3 | import {DescriptionOutlined} from "@mui/icons-material";
4 | import * as React from "react";
5 | import {BaseTextFieldProps} from "@mui/material";
6 |
7 | const name = 'description';
8 |
9 | const SnippetDescriptionInput: React.FC = (props) => {
10 | const useFormMethods = useFormContext()
11 |
12 | return (
13 |
18 |
24 | }}
25 | />
26 | }
27 | />
28 | )
29 | }
30 |
31 | export default SnippetDescriptionInput;
32 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Base/Input/Snippet/Name/SnippetNameInput.tsx:
--------------------------------------------------------------------------------
1 | import {Controller, useFormContext} from "react-hook-form";
2 | import * as React from "react";
3 | import {DriveFileRenameOutlineOutlined} from "@mui/icons-material";
4 | import BaseOutlinedInput from "../../BaseOutlinedInput/BaseOutlinedInput";
5 | import {BaseTextFieldProps} from "@mui/material";
6 |
7 | const name = 'title'
8 |
9 | const SnippetNameInput: React.FC = (props): React.ReactElement => {
10 | const useFormMethods = useFormContext()
11 |
12 | return (
13 |
18 |
24 | }}
25 | />
26 | }
27 | />
28 | )
29 | }
30 |
31 |
32 | export default SnippetNameInput
33 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Base/Input/UserName/UserNameInput.tsx:
--------------------------------------------------------------------------------
1 | import {Controller, useFormContext} from "react-hook-form";
2 | import * as React from "react";
3 | import BaseOutlinedInput from "../BaseOutlinedInput/BaseOutlinedInput";
4 | import {PersonOutlined} from "@mui/icons-material";
5 |
6 | const name = 'username'
7 |
8 | const UserNameInput = (): React.ReactElement => {
9 | const useFormMethods = useFormContext()
10 |
11 | return (
12 |
17 |
21 | }}
22 | />
23 | }
24 | />
25 | )
26 | }
27 |
28 |
29 | export default UserNameInput
30 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Base/Popup/BasePopupText.tsx:
--------------------------------------------------------------------------------
1 | import {
2 | bindPopover,
3 | bindTrigger,
4 | usePopupState,
5 | } from "material-ui-popup-state/hooks";
6 | import { IconButton, Popover } from "@mui/material";
7 | import React from "react";
8 |
9 | interface IBasePopupProps {
10 | children: React.ReactNode;
11 | text: string;
12 | }
13 |
14 | const BasePopupText: React.FC = (props) => {
15 | const popupState = usePopupState({
16 | variant: "popover",
17 | popupId: "textPopup",
18 | });
19 |
20 | return (
21 | <>
22 | {props.text}
23 |
24 |
35 | {props.children}
36 |
37 | >
38 | );
39 | };
40 |
41 | export default BasePopupText;
42 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Base/Theme/SwitchThemeButton.tsx:
--------------------------------------------------------------------------------
1 | import React, {useCallback} from "react";
2 | import {NightsStayOutlined, WbSunnyOutlined} from "@mui/icons-material";
3 | import {IconButton, useTheme} from "@mui/material";
4 | import {useRecoilState} from "recoil";
5 | import {themeModState} from "../../../themes/RThemeStates";
6 |
7 | const SwitchThemeButton = (): React.ReactElement => {
8 | const theme = useTheme()
9 | const [themeMode, setThemeMode] = useRecoilState(themeModState)
10 |
11 | const handleThemeSwitch = useCallback(() => {
12 | const appTheme = themeMode === 'light' ? 'dark' : 'light'
13 | setThemeMode(appTheme)
14 | localStorage.setItem('theme', appTheme)
15 | }, [setThemeMode, themeMode])
16 |
17 | return (
18 |
19 | {theme.palette.mode === 'light' ? ( ) : ( )}
20 |
21 | )
22 | }
23 |
24 | export default SwitchThemeButton
25 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Layout/ContainerLayout.tsx:
--------------------------------------------------------------------------------
1 | import { Outlet } from "react-router-dom";
2 | import * as React from "react";
3 | import { Container } from "@mui/material";
4 |
5 | const ContainerLayout = (): React.ReactElement => {
6 | return (
7 |
8 |
9 |
10 | );
11 | };
12 |
13 | export default ContainerLayout;
14 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Layout/SideBar/_sideList.tsx:
--------------------------------------------------------------------------------
1 | import SideListItem, {SideListItemProps} from "./_sideListItem";
2 | import * as React from "react";
3 |
4 | interface SideListProps {
5 | data: SideListItemProps[]
6 | }
7 |
8 | const SideList: React.FC = (props) => {
9 | const {data} = props;
10 | return (
11 | <>
12 | {data.map((item, index) =>
13 |
14 | )}
15 | >
16 | )
17 | }
18 |
19 | export default SideList;
20 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Layout/TopBar/DevModeAlert.tsx:
--------------------------------------------------------------------------------
1 | import Box from "@mui/material/Box";
2 | import React from "react";
3 |
4 | const DevModeAlert = () => {
5 | return (
6 |
7 | This site under the development mode, Your data will not be saved constantly.
8 |
9 | )
10 | }
11 |
12 | export default DevModeAlert;
13 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Layout/TopBar/RightButton.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {Box} from "@mui/material";
3 | import SharePopup from "../../Share/SharePopup";
4 | import {useMatch} from "react-router-dom";
5 |
6 | interface IRightButtonProps {
7 | href: string;
8 | render: React.ReactNode;
9 | tooltip: string;
10 | }
11 |
12 | const RightButton = (): React.ReactElement => {
13 | const userSnippetPage = useMatch('/s/:userId/:snippetId')
14 |
15 | return (
16 | <>
17 | {userSnippetPage && (
18 |
19 |
25 |
26 | )}
27 |
28 |
29 | >
30 | );
31 | };
32 |
33 | export default RightButton;
34 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Layout/TopBar/_fullScreenButton.tsx:
--------------------------------------------------------------------------------
1 | import {FullscreenOutlined} from "@mui/icons-material";
2 | import {Button} from "@mui/material";
3 | import React from "react";
4 | import {useRecoilState} from "recoil";
5 | import {resultFullScreenState} from "../../../states/RLayoutStates";
6 |
7 | const FullScreenButton = () => {
8 | const [resultFullScreen, setResultFullScreen] = useRecoilState(resultFullScreenState);
9 |
10 | return (
11 | setResultFullScreen(!resultFullScreen)}
15 | endIcon={ }>
16 | Fullscreen
17 |
18 | )
19 | }
20 |
21 | export default FullScreenButton
22 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Layout/TopBar/_gitHubButton.tsx:
--------------------------------------------------------------------------------
1 | import {GitHub} from "@mui/icons-material";
2 | import {Box, Button} from "@mui/material";
3 | import React, {useEffect} from "react";
4 | import useSWR from "swr";
5 | import {fetcher} from "../../../network/fetcher";
6 |
7 | const GitHubButton = () => {
8 | const [githubStargazersCount, setGithubStargazersCount] = React.useState(0);
9 | const {data: githubStars} = useSWR('https://api.github.com/repos/Hedgehog-Computing/hedgehog-lab', fetcher, {revalidateOnFocus: false});
10 |
11 | useEffect(() => {
12 | setGithubStargazersCount(githubStars?.stargazers_count ?? 0)
13 | }, [githubStars])
14 |
15 | return (
16 | } target={'_blank'} href={'https://github.com/Hedgehog-Computing/hedgehog-lab'}>
19 | Github
20 |
21 | {githubStargazersCount > 0 && (
22 |
23 | {githubStargazersCount.toLocaleString('en-US')}
24 |
25 | )}
26 |
27 |
28 | )
29 | }
30 |
31 | export default GitHubButton;
32 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Meta/Meta.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Helmet } from "react-helmet-async";
3 | import type { MetaProps } from './types';
4 |
5 | function Meta({
6 | title,
7 | }: MetaProps) {
8 | const pageTitle = `${title ? title : 'Hlab'} - Hedgehog Lab`;
9 |
10 | return (
11 |
14 | )
15 | }
16 |
17 | export default Meta;
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/Meta/types.ts:
--------------------------------------------------------------------------------
1 |
2 | type MetaProps = {
3 | title?: string;
4 | };
5 |
6 | export type { MetaProps };
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/YourCode/Config/SideBar.ts:
--------------------------------------------------------------------------------
1 | export const sideBarWidth = 120;
2 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/YourCode/Header/YourCodeHeader.tsx:
--------------------------------------------------------------------------------
1 | import {Box} from "@mui/material";
2 | import React from "react";
3 | import SaveState from "../../Snippet/Save/SaveState";
4 |
5 | const YourCodeHeader = (): React.ReactElement => {
6 | return (
7 |
16 |
17 |
18 | );
19 | };
20 |
21 | export default YourCodeHeader;
22 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/components/styled.ts:
--------------------------------------------------------------------------------
1 | import {styled} from "@mui/styles";
2 | import {Drawer, Link, Typography} from "@mui/material";
3 | import {sideBarWidth} from "./YourCode/Config/SideBar";
4 |
5 | export const NowrapTypography = styled(Typography)({
6 | whiteSpace: "nowrap",
7 | overflow: "hidden",
8 | textOverflow: "ellipsis",
9 | })
10 |
11 | export const PlainLink = styled(Link)({
12 | textDecoration: "none",
13 | color: "inherit",
14 | '&:hover': {
15 | textDecoration: "none",
16 | }
17 | })
18 |
19 | export const ResponseDrawer = styled(Drawer)({
20 | width: sideBarWidth,
21 | flexShrink: 0,
22 | [`& .MuiDrawer-paper`]: {
23 | width: sideBarWidth,
24 | boxSizing: "border-box"
25 | }
26 | })
27 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/config.tsx:
--------------------------------------------------------------------------------
1 | const HEDGEHOG_DOMAIN = 'https://hlab.app';
2 |
3 | export {
4 | HEDGEHOG_DOMAIN
5 | }
6 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/hooks/useApp.tsx:
--------------------------------------------------------------------------------
1 | const useApp = () => {
2 | const hostPath = window.location.host
3 |
4 | const isDevPath = hostPath !== 'hlab.app'
5 |
6 | return {
7 | isDevPath
8 | }
9 | }
10 |
11 | export default useApp
12 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/hooks/useCurrentRoute.ts:
--------------------------------------------------------------------------------
1 | import {useLocation} from 'react-router-dom';
2 | import {IAppRoutes, router} from "../route/route";
3 |
4 | const useCurrentRoute = () => {
5 | const {pathname} = useLocation();
6 | let currentRoute: IAppRoutes = {};
7 |
8 | router.map((route: IAppRoutes) => {
9 | if (route.children) {
10 | route.children.map((child) => {
11 | if (child.path === pathname && !child.children) {
12 | currentRoute = child;
13 | }
14 |
15 | if (child.children) {
16 | child.children.map((item) => {
17 | if (`${child.path}/${item.path}` === pathname) {
18 | currentRoute = item;
19 | }
20 | })
21 | }
22 | });
23 | }
24 | });
25 |
26 | return currentRoute;
27 | };
28 |
29 | export default useCurrentRoute;
30 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/hooks/useSnippet.ts:
--------------------------------------------------------------------------------
1 | import {http} from "../network/http";
2 | import {useRecoilState} from "recoil";
3 | import {dialogState} from "../states/RSnippetStates";
4 | import {useCallback, useState} from "react";
5 |
6 | interface ICreateSnippet {
7 | title: string;
8 | content: string;
9 | description?: string,
10 | }
11 |
12 | interface IUpdateSnippet {
13 | id: string;
14 | title: string;
15 | content: string;
16 | description?: string,
17 | }
18 |
19 | export const useSnippet = () => {
20 | const [createDialog, setCreateDialog] = useRecoilState(dialogState)
21 | const [createLoading, setCreateLoading] = useState(false)
22 | const [updateLoading, setUpdateLoading] = useState(false)
23 |
24 | const createSnippet = useCallback((data: ICreateSnippet) => {
25 | setCreateLoading(true)
26 | return http.post('snippets/create', data).finally(() => setCreateLoading(false))
27 | }, [])
28 |
29 | const updateSnippet = useCallback((data: IUpdateSnippet) => {
30 | setUpdateLoading(true)
31 | return http.post('snippets/update', data).finally(() => setUpdateLoading(false))
32 | }, [])
33 |
34 | return {createSnippet, createDialog, setCreateDialog, createLoading, setCreateLoading, updateSnippet, updateLoading}
35 | };
36 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/hooks/useSystemTheme.ts:
--------------------------------------------------------------------------------
1 | import {useEffect, useState} from 'react'
2 |
3 | const getMql = () => {
4 | if (typeof window === 'undefined') {
5 | return
6 | }
7 | return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)')
8 | }
9 |
10 | const getSystemTheme = (matches: boolean) => (matches ? 'dark' : 'light')
11 |
12 | export type SystemTheme = 'dark' | 'light'
13 |
14 | const getDefaultTheme = (isSSR: boolean): SystemTheme => {
15 | if (!isSSR) {
16 | const mql = getMql()
17 | if (mql) {
18 | return getSystemTheme(mql.matches)
19 | }
20 | }
21 | return 'light'
22 | }
23 |
24 | const useSystemTheme = (isSSR = false): string => {
25 | const defaultTheme = getDefaultTheme(isSSR)
26 | const [systemTheme, setSystemTheme] = useState(defaultTheme)
27 | useEffect(() => {
28 | const mql = getMql()
29 | const mqlListener = (e: any) => setSystemTheme(getSystemTheme(e.matches))
30 | if (mql) {
31 | setSystemTheme(getSystemTheme(mql.matches))
32 | mql.addListener(mqlListener)
33 | }
34 | return () => mql && mql.removeListener(mqlListener)
35 | }, [])
36 | return systemTheme
37 | }
38 |
39 | export default useSystemTheme
40 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import './index.css';
3 | import App from './App';
4 | import * as serviceWorkerRegistration from './serviceWorkerRegistration';
5 | import {createRoot} from "react-dom/client";
6 |
7 | const container = document.getElementById('root');
8 | // @ts-ignore
9 | const root = createRoot(container);
10 |
11 | root.render( )
12 | // If you want your app to work offline and load faster, you can change
13 | // unregister() to register() below. Note this comes with some pitfalls.
14 | // Learn more about service workers: https://bit.ly/CRA-PWA
15 | serviceWorkerRegistration.register();
16 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/interfaces/IFormInput.ts:
--------------------------------------------------------------------------------
1 | import {InputBaseProps} from "@mui/material";
2 |
3 | export interface IFormInput {
4 | username?: string,
5 | email?: string,
6 | password?: string,
7 | showPassword?: boolean
8 | }
9 |
10 | export interface IInputProps extends Partial {
11 | defaultValue?: string
12 | }
13 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/interfaces/ISnippetName.ts:
--------------------------------------------------------------------------------
1 | export interface ISnippetName {
2 | name: string;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/models/account/accountModal.ts:
--------------------------------------------------------------------------------
1 | import * as yup from "yup";
2 | import {IFormInput} from "../../interfaces/IFormInput";
3 |
4 | export const accountModal = (data: IFormInput): void => {
5 | console.log(data)
6 | }
7 |
8 | export const accountRule = yup.object({
9 | username: yup.string().required(),
10 | email: yup.string().email().required(),
11 | password: yup.string().min(6).required()
12 | }).required();
13 |
14 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/models/forget/forgetModal.ts:
--------------------------------------------------------------------------------
1 | import * as yup from "yup";
2 | import {IFormInput} from "../../interfaces/IFormInput";
3 |
4 | export const forgetModal = (data: IFormInput): void => {
5 | console.log(data)
6 | }
7 |
8 | export const forgetRule = yup.object({
9 | email: yup.string().email().required(),
10 | }).required();
11 |
12 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/models/login/loginModal.ts:
--------------------------------------------------------------------------------
1 | import * as yup from "yup";
2 |
3 |
4 | export const loginRule = yup.object({
5 | email: yup.string().email().required(),
6 | password: yup.string().min(6).required()
7 | }).required();
8 |
9 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/models/sign/signModel.ts:
--------------------------------------------------------------------------------
1 | import * as yup from "yup";
2 |
3 | export const signRule = yup.object({
4 | username: yup.string().required(),
5 | email: yup.string().email().required(),
6 | password: yup.string().min(6).required()
7 | }).required();
8 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/models/snippet/renameModal.ts:
--------------------------------------------------------------------------------
1 | import * as yup from "yup";
2 | import {ISnippetName} from "../../interfaces/ISnippetName";
3 |
4 | export const renameModal = (data: ISnippetName): void => {
5 | console.log(data)
6 | }
7 |
8 | export const renameRule = yup.object({
9 | name: yup.string().required(),
10 | }).required();
11 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/network/fetcher.ts:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 |
3 | export const fetcher = (url: string) => axios.get(url).then(res => res.data)
4 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/network/http.ts:
--------------------------------------------------------------------------------
1 | import axios from "axios";
2 |
3 | const hostname = window.location.hostname;
4 |
5 | let url
6 | switch (hostname) {
7 | case "preview.hlab.app":
8 | url = "https://api.preview.hlab.app";
9 | break;
10 | case "hlab.app":
11 | url = "https://api.hlab.app";
12 | break;
13 | default:
14 | url = "https://api.hlab.app";
15 | }
16 |
17 | axios.defaults.timeout = 100000;
18 | axios.defaults.baseURL = url;
19 |
20 | export const http = axios;
21 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/output.worker.ts:
--------------------------------------------------------------------------------
1 | import * as Comlink from 'comlink';
2 | import { executeOutput } from '@hedgehogcomputing/core';
3 |
4 | const outputWorker = {
5 | output: async (e: any) => executeOutput(e)
6 | };
7 |
8 | Comlink.expose(outputWorker);
9 |
10 | export default null as any;
11 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Draft/Draft.tsx:
--------------------------------------------------------------------------------
1 | import React, {useEffect} from "react";
2 | import {useEditor} from "../../hooks/useEditor";
3 | import Editor from "../../components/Base/Editor/Editor";
4 | import Meta from '../../components/Meta/Meta';
5 | import HedgehogLab from "@hedgehogcomputing/lab/src/HedgehogLab";
6 |
7 | const Draft = () => {
8 | const {editorCode, setEditorCode} = useEditor();
9 | const lastRunningCode = localStorage.getItem("lastRunningCode");
10 |
11 | useEffect(() => {
12 | if (editorCode === "") {
13 | setEditorCode(lastRunningCode);
14 | }
15 | }, [editorCode])
16 |
17 | return (
18 | <>
19 |
20 |
21 | >
22 |
23 | )
24 | }
25 |
26 | export default Draft;
27 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Email/EmailVerification.tsx:
--------------------------------------------------------------------------------
1 | import {Box, Button} from "@mui/material";
2 | import React from "react";
3 |
4 |
5 | const EmailVerification = () => {
6 | return (
7 | <>
8 |
9 | Verification
10 |
11 | Back to Home
12 |
13 | >
14 | );
15 | };
16 |
17 | export default EmailVerification;
18 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Example/Example.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Editor from "../../components/Base/Editor/Editor";
3 | import {tutorials} from "../../tutorials";
4 | import {useEditor} from "../../hooks/useEditor";
5 | import {useMatch} from "react-router-dom";
6 | import {useEffectOnce} from "react-use";
7 | import Meta from '../../components/Meta/Meta';
8 |
9 | const Example = () => {
10 | const {setEditorCode} = useEditor();
11 | const mathExamplePage = useMatch('/e/example/:exampleName')
12 |
13 | useEffectOnce(() => {
14 | const title = mathExamplePage?.params.exampleName
15 | const currentObj = tutorials.find(o => o.description === title) ?? {
16 | 'description': 'Empty',
17 | 'source': ''
18 | }
19 |
20 | setEditorCode(currentObj?.source)
21 | })
22 |
23 | return (
24 | <>
25 |
26 |
27 | >
28 | );
29 | }
30 |
31 | export default Example;
32 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Explore/Explore.tsx:
--------------------------------------------------------------------------------
1 | import { Box } from "@mui/system";
2 | import React from "react";
3 | import SnippetList from "../../components/Snippet/List/SnippetList";
4 | import SearchSnippet from "../../components/Snippet/Search/SearchSnippet";
5 | import Snippet from "../../components/Snippet/Snippet";
6 | import Meta from '../../components/Meta/Meta';
7 |
8 | const Explore = () => {
9 | return (
10 | <>
11 |
12 |
13 | >
14 | );
15 | };
16 |
17 | export default Explore;
18 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Home/Home.tsx:
--------------------------------------------------------------------------------
1 | import React, {useEffect} from "react";
2 | import GettingStarted from "./_gettingStarted";
3 | import Community from "./_community";
4 | import {Stack} from "@mui/material";
5 | import Draft from "./_draft";
6 | import Meta from '../../components/Meta/Meta';
7 | import {toast} from "react-toastify";
8 |
9 | const Home = () => {
10 | return (
11 | <>
12 |
13 |
14 |
15 |
16 |
17 |
18 | >
19 | )
20 | }
21 |
22 | export default Home;
23 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Home/_community.tsx:
--------------------------------------------------------------------------------
1 | import Title from "./_title";
2 | import React from "react";
3 | import {Box, Grid} from "@mui/material";
4 | import useSWR from "swr";
5 | import {fetcher} from "../../network/fetcher";
6 | import GridItem from "./_gridItem";
7 |
8 | const Community = () => {
9 | const {data, error} = useSWR('/snippets/all?size=10&from=1', fetcher)
10 | return (
11 |
12 |
13 |
14 |
15 | {data && data?.response?.result.map((snippet: {
16 | user: { username: string };
17 | title: string;
18 | description: string;
19 | }, index: number) => {
20 | return (
21 |
23 | )
24 | })}
25 |
26 |
27 | )
28 | }
29 |
30 | export default Community;
31 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Home/_draft.tsx:
--------------------------------------------------------------------------------
1 | import {Box} from "@mui/material";
2 | import Title from "./_title";
3 | import React from "react";
4 | import GridItem from "./_gridItem";
5 |
6 | const Draft = () => {
7 | const lastRunningCode = localStorage.getItem("lastRunningCode");
8 | return (
9 | <>
10 | {
11 | lastRunningCode && (
12 |
13 |
14 |
15 |
16 |
17 | )
18 | }
19 | >
20 | )
21 | }
22 |
23 | export default Draft;
24 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Home/_gettingStarted.tsx:
--------------------------------------------------------------------------------
1 | import {Box, Grid} from "@mui/material";
2 | import {tutorials} from "../../tutorials";
3 | import React from "react";
4 | import Title from "./_title";
5 | import GridItem from "./_gridItem";
6 |
7 | const GettingStarted = () => {
8 | return (
9 |
10 |
11 |
12 |
13 | {tutorials.map((tutorial, index) => {
14 | return (
15 |
16 | );
17 | })}
18 |
19 |
20 | )
21 | }
22 |
23 | export default GettingStarted;
24 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Home/_gridItem.tsx:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import {Grid, Link, Paper} from "@mui/material";
3 | import {Link as RouterLink} from "react-router-dom";
4 | import {NowrapTypography} from "../../components/styled";
5 |
6 | interface GridItemProps {
7 | link: string;
8 | title: string;
9 | description?: string;
10 | }
11 |
12 | const GridItem: React.FC = (props) => {
13 | const {link, title, description} = props;
14 |
15 | return (
16 |
17 |
20 |
21 |
22 | {title}
23 |
24 |
25 |
26 | {description}
27 |
28 |
29 |
30 |
31 | )
32 | }
33 |
34 | export default GridItem
35 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/pages/Home/_title.tsx:
--------------------------------------------------------------------------------
1 | import {Divider, Typography} from "@mui/material";
2 | import React from "react";
3 |
4 | interface TitleProps {
5 | title: string;
6 | }
7 |
8 | const Title: React.FC = (props) => {
9 | const {title} = props;
10 |
11 | return (
12 | <>
13 |
14 | {title}
15 |
16 |
17 |
18 | >
19 | )
20 | }
21 |
22 | export default Title;
23 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.worker.ts' {
4 | class WebpackWorker extends Worker {
5 | constructor();
6 | }
7 |
8 | export default WebpackWorker;
9 | }
10 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/states/RCompilerStates.ts:
--------------------------------------------------------------------------------
1 | import {atom} from "recoil";
2 |
3 | export const compilerLoadingState = atom({
4 | key: "compilerLoading",
5 | default: false,
6 | });
7 |
8 | export const compilerResultState = atom({
9 | key: "compilerResult",
10 | default: {
11 | outputItem: [],
12 | outputString: "",
13 | },
14 | });
15 |
16 | export const compilerReFetchState = atom({
17 | key: "compilerReFetch",
18 | default: false,
19 | });
20 |
21 | export const compilerLiveModeState = atom({
22 | key: "compilerLiveMode",
23 | default: "on",
24 | });
25 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/states/RLayoutStates.ts:
--------------------------------------------------------------------------------
1 | import { atom } from "recoil";
2 |
3 | export const sideBarOpenState = atom({
4 | key: "sideBarOpen",
5 | default: false,
6 | });
7 |
8 | export const resultFullScreenState = atom({
9 | key: "resultFullScreen",
10 | default: false,
11 | });
12 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/states/RYourCodeStates.ts:
--------------------------------------------------------------------------------
1 | import {atom, selector} from "recoil";
2 |
3 | export const codeSavingFlagState = atom({
4 | key: 'codeSavingFlag',
5 | default: false
6 | })
7 |
8 | interface IEditorMetaState {
9 | title: string
10 | currentFile?: string,
11 | id: string,
12 | description: string,
13 | }
14 |
15 | const editorMetaAtom = atom({
16 | key: "editorMetaAtom",
17 | default: {
18 | title: '',
19 | currentFile: '',
20 | id: '',
21 | description: '',
22 | },
23 | });
24 |
25 |
26 | export const editorMetaState = selector({
27 | key: "editorMetaState",
28 | get: async ({get}) => {
29 | return get(editorMetaAtom);
30 | },
31 | set: ({set}, newValue: any) => {
32 | set(editorMetaAtom, newValue);
33 | }
34 | });
35 |
36 |
37 | export const editorCodeState = atom({
38 | key: 'editorCode',
39 | default: ''
40 | })
41 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/themes/RThemeStates.ts:
--------------------------------------------------------------------------------
1 | import {atom} from "recoil";
2 |
3 | export const themeModState = atom({
4 | key: 'themeModState',
5 | default: 'light'
6 | })
7 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/utils/ga4.js:
--------------------------------------------------------------------------------
1 | import ReactGA from 'react-ga4'
2 |
3 | const hostname = window.location.hostname;
4 |
5 | let gaID
6 | switch (hostname) {
7 | case "preview.hlab.app":
8 | gaID = "G-FLQZFQEJBL";
9 | break;
10 | case "hlab.app":
11 | gaID = "G-6RED8ZS8V6";
12 | break;
13 | default:
14 | gaID = "G-FLQZFQEJBL";
15 | }
16 |
17 | // initialize Google Analytics
18 | ReactGA.initialize(gaID)
19 |
20 |
21 | // custom pageview with the location from react router
22 | export const pageView = path => {
23 | return ReactGA.send({hitType: 'pageview', page: path})
24 | }
25 |
26 | // custom event with label being an optional parameter
27 | export const customEvent = (category, action, label = '') => {
28 | return ReactGA.event({
29 | category: category,
30 | action: action,
31 | label: label,
32 | })
33 | }
34 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/utils/kFormatter.ts:
--------------------------------------------------------------------------------
1 | export const kFormatter = (num: number) => {
2 | return Math.abs(num) > 999 ? Math.sign(num) * parseFloat(((Math.abs(num) / 1000).toFixed(1))) + 'k' : Math.sign(num) * Math.abs(num)
3 | }
4 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/src/utils/toCapitalize.ts:
--------------------------------------------------------------------------------
1 | const toCapitalize = (string: string): string => {
2 | return string.toLowerCase().replace(/(^\w)|(\s\w)/g, match => match.toUpperCase())
3 | }
4 |
5 | export default toCapitalize
6 |
--------------------------------------------------------------------------------
/packages/hedgehog-website/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "esModuleInterop": true,
8 | "allowSyntheticDefaultImports": true,
9 | "strict": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "noEmit": true,
16 | "jsx": "react"
17 | },
18 | "include": ["src"]
19 | }
20 |
--------------------------------------------------------------------------------
/patches/gpu.js+2.11.4.patch:
--------------------------------------------------------------------------------
1 | diff --git a/node_modules/gpu.js/package.json b/node_modules/gpu.js/package.json
2 | index fc65b7e..a8880ce 100644
3 | --- a/node_modules/gpu.js/package.json
4 | +++ b/node_modules/gpu.js/package.json
5 | @@ -19,7 +19,7 @@
6 | },
7 | "dependencies": {
8 | "acorn": "^7.1.1",
9 | - "gl": "^4.5.2",
10 | + "gl": "^4.9.2",
11 | "gl-wiretap": "^0.6.2",
12 | "gpu-mock.js": "^1.3.0"
13 | },
14 |
--------------------------------------------------------------------------------
/scripts/publish-to-github.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | VERSION=$(jq -r '.version' package.json)
3 | cd packages/hedgehog-core || echo "cannot find module hedgehog-core"
4 | npm --no-git-tag-version version "$VERSION-$BUILD_VERSION"
5 | npm publish
6 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["packages/*/src"],
3 | "compilerOptions": {
4 | "declaration": true,
5 | "declarationMap": true,
6 | "sourceMap": true,
7 | "strict": true,
8 | "skipLibCheck": true,
9 | "module": "esnext",
10 | "moduleResolution": "node",
11 | "esModuleInterop": true,
12 | "resolveJsonModule": true,
13 | "isolatedModules": true,
14 | "baseUrl": ".",
15 | "paths": {
16 | "@hedgehogcomputing/*": ["packages/*/src"]
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/vercel.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "builds": [
4 | {
5 | "src": "package.json",
6 | "use": "@vercel/node"
7 | }
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------