Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix #3162: add license information about CSParse #3164

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ Thanks Github Actions and BrowserStack for the generous free hosting of this ope

## License

mathjs is published under the Apache 2.0 license:

```
Copyright (C) 2013-2024 Jos de Jong <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -208,3 +211,28 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

mathjs contains a JavaScript port of the [CSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source) library, published under the LGPL-2.1+ license:

```
CSparse: a Concise Sparse matrix package.
Copyright (c) 2006, Timothy A. Davis.
http://www.suitesparse.com

--------------------------------------------------------------------------------

CSparse is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

CSparse is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this Module; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
```
12 changes: 12 additions & 0 deletions src/function/algebra/sparse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# CSparse

This folder contains a JavaScript port of the `CSparse` section of the open source `SuiteSparse` library by Timothy A. Davis, see:

https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source


```
CSparse: a Concise Sparse matrix package.
Copyright (c) 2006, Timothy A. Davis.
http://www.suitesparse.com
```
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csAmd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { factory } from '../../../utils/factory.js'
import { csFkeep } from './csFkeep.js'
import { csFlip } from './csFlip.js'
Expand All @@ -17,8 +20,6 @@ export const createCsAmd = /* #__PURE__ */ factory(name, dependencies, ({ add, m
* than A. It is a gready method that selects the sparsest pivot row and column during the course
* of a right looking sparse Cholesky factorization.
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*
* @param {Number} order 0: Natural, 1: Cholesky, 2: LU, 3: QR
* @param {Matrix} m Sparse Matrix
*/
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csChol.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { factory } from '../../../utils/factory.js'
import { csEreach } from './csEreach.js'
import { createCsSymperm } from './csSymperm.js'
Expand Down Expand Up @@ -40,8 +43,6 @@ export const createCsChol = /* #__PURE__ */ factory(name, dependencies, (
* @param {Object} s The symbolic analysis from cs_schol()
*
* @return {Number} The numeric Cholesky factorization of A or null
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
return function csChol (m, s) {
// validate input
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csCounts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { factory } from '../../../utils/factory.js'
import { csLeaf } from './csLeaf.js'

Expand All @@ -16,8 +19,6 @@ export const createCsCounts = /* #__PURE__ */ factory(name, dependencies, ({ tra
* @param {Matrix} ata Count the columns of A'A instead
*
* @return An array of size n of the column counts or null on error
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
return function (a, parent, post, ata) {
// check inputs
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csCumsum.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* It sets the p[i] equal to the sum of c[0] through c[i-1].
*
* @param {Array} ptr The Sparse Matrix ptr array
* @param {Array} c The Sparse Matrix ptr array
* @param {Number} n The number of columns
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csCumsum (ptr, c, n) {
// variables
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csDfs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { csMarked } from './csMarked.js'
import { csMark } from './csMark.js'
import { csUnflip } from './csUnflip.js'
Expand All @@ -15,8 +18,6 @@ import { csUnflip } from './csUnflip.js'
* @param {Array} pinv The inverse row permutation vector, must be null for L * x = b
*
* @return {Number} New value of top
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csDfs (j, g, top, xi, pinv) {
// g arrays
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csEreach.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { csMark } from './csMark.js'
import { csMarked } from './csMarked.js'

Expand All @@ -11,8 +14,6 @@ import { csMarked } from './csMarked.js'
* The first n entries is the nonzero pattern, the last n entries is the stack
*
* @return {Number} The index for the nonzero pattern
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csEreach (a, k, parent, w) {
// a arrays
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csEtree.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* Computes the elimination tree of Matrix A (using triu(A)) or the
* elimination tree of A'A without forming A'A.
*
* @param {Matrix} a The A Matrix
* @param {boolean} ata A value of true the function computes the etree of A'A
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csEtree (a, ata) {
// check inputs
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csFkeep.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* Keeps entries in the matrix when the callback function returns true, removes the entry otherwise
*
Expand All @@ -10,8 +14,6 @@
* @param {any} other The state
*
* @return The number of nonzero elements in the matrix
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csFkeep (a, callback, other) {
// a arrays
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csFlip.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* This function "flips" its input about the integer -1.
*
* @param {Number} i The value to flip
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csFlip (i) {
// flip the value
Expand Down
4 changes: 4 additions & 0 deletions src/function/algebra/sparse/csIpvec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* Permutes a vector; x = P'b. In MATLAB notation, x(p)=b.
*
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csLeaf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* This function determines if j is a leaf of the ith row subtree.
* Consider A(i,j), node j in ith row subtree and return lca(jprev,j)
Expand All @@ -11,8 +15,6 @@
* @param {Number} ancestor The index offset within the workspace for the ancestor array
*
* @return {Object}
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csLeaf (i, j, w, first, maxfirst, prevleaf, ancestor) {
let s, sparent
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csLu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

import { factory } from '../../../utils/factory.js'
import { createCsSpsolve } from './csSpsolve.js'

Expand Down Expand Up @@ -27,8 +31,6 @@ export const createCsLu = /* #__PURE__ */ factory(name, dependencies, ({ abs, di
* @param {Number} tol Partial pivoting threshold (1 for partial pivoting)
*
* @return {Number} The numeric LU factorization of A or null
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
return function csLu (m, s, tol) {
// validate input
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csMark.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

import { csFlip } from './csFlip.js'

/**
* Marks the node at w[j]
*
* @param {Array} w The array
* @param {Number} j The array index
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csMark (w, j) {
// mark w[j]
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csMarked.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* Checks if the node at w[j] is marked
*
* @param {Array} w The array
* @param {Number} j The array index
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csMarked (w, j) {
// check node is marked
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csPermute.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* Permutes a sparse matrix C = P * A * Q
*
Expand All @@ -7,8 +11,6 @@
* @param {boolean} values Create a pattern matrix (false), values and pattern otherwise
*
* @return {Matrix} C = P * A * Q, null on error
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csPermute (a, pinv, q, values) {
// a arrays
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csPost.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { csTdfs } from './csTdfs.js'

/**
* Post order a tree of forest
*
* @param {Array} parent The tree or forest
* @param {Number} n Number of columns
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csPost (parent, n) {
// check inputs
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csReach.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

import { csMarked } from './csMarked.js'
import { csMark } from './csMark.js'
import { csDfs } from './csDfs.js'
Expand All @@ -15,8 +19,6 @@ import { csDfs } from './csDfs.js'
* @param {Array} pinv The inverse row permutation vector
*
* @return {Number} The index for the nonzero pattern
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csReach (g, b, k, xi, pinv) {
// g arrays
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csSpsolve.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { csReach } from './csReach.js'
import { factory } from '../../../utils/factory.js'

Expand Down Expand Up @@ -25,8 +28,6 @@ export const createCsSpsolve = /* #__PURE__ */ factory(name, dependencies, ({ di
* @param {boolean} lo The lower (true) upper triangular (false) flag
*
* @return {Number} The index for the nonzero pattern
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
return function csSpsolve (g, b, k, xi, x, pinv, lo) {
// g arrays
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csSqr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { csPermute } from './csPermute.js'
import { csPost } from './csPost.js'
import { csEtree } from './csEtree.js'
Expand Down Expand Up @@ -25,8 +28,6 @@ export const createCsSqr = /* #__PURE__ */ factory(name, dependencies, ({ add, m
* symbolic ordering and analysis for LU decomposition (false)
*
* @return {Object} The Symbolic ordering and analysis for matrix A
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
return function csSqr (order, a, qr) {
// a arrays
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csSymperm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { csCumsum } from './csCumsum.js'
import { factory } from '../../../utils/factory.js'

Expand All @@ -16,8 +19,6 @@ export const createCsSymperm = /* #__PURE__ */ factory(name, dependencies, ({ co
* @param {boolean} values Process matrix values (true)
*
* @return {Matrix} The C matrix, C = P * A * P'
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
return function csSymperm (a, pinv, values) {
// A matrix arrays
Expand Down
6 changes: 4 additions & 2 deletions src/function/algebra/sparse/csTdfs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source

/**
* Depth-first search and postorder of a tree rooted at node j
*
Expand All @@ -8,8 +12,6 @@
* @param {Number} next The index offset within the workspace for the next array
* @param {Array} post The post ordering array
* @param {Number} stack The index offset within the workspace for the stack array
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csTdfs (j, k, w, head, next, post, stack) {
// variables
Expand Down
5 changes: 3 additions & 2 deletions src/function/algebra/sparse/csUnflip.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) 2006-2024, Timothy A. Davis, All Rights Reserved.
// SPDX-License-Identifier: LGPL-2.1+
// https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/CSparse/Source
import { csFlip } from './csFlip.js'

/**
* Flips the value if it is negative of returns the same value otherwise.
*
* @param {Number} i The value to flip
*
* Reference: http://faculty.cse.tamu.edu/davis/publications.html
*/
export function csUnflip (i) {
// flip the value if it is negative
Expand Down