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
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
fix #3162: add license information about CSParse
josdejong committed Feb 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b50e0ed4b492978edf1278e5598f3bd38ced444e
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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");
@@ -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'
@@ -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
*/
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'
@@ -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
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'

@@ -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
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
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'
@@ -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
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'

@@ -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
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
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
*
@@ -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
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
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.
*
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)
@@ -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
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'

@@ -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
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]
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
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
*
@@ -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
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
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'
@@ -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
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'

@@ -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
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'
@@ -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
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'

@@ -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
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
*
@@ -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
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