https://github.com/konstantin8105/sparse
Transpilated CSparse from C to Go
https://github.com/konstantin8105/sparse
c c4go golang linear-algebra sparse
Last synced: about 1 month ago
JSON representation
Transpilated CSparse from C to Go
- Host: GitHub
- URL: https://github.com/konstantin8105/sparse
- Owner: Konstantin8105
- License: lgpl-2.1
- Created: 2018-11-14T08:07:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-30T14:17:39.000Z (over 1 year ago)
- Last Synced: 2025-02-01T13:29:51.652Z (about 1 year ago)
- Topics: c, c4go, golang, linear-algebra, sparse
- Language: C
- Size: 3.15 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sparse
[](https://goreportcard.com/report/github.com/Konstantin8105/sparse)
[](https://codecov.io/gh/Konstantin8105/sparse)
[](https://github.com/Konstantin8105/sparse/blob/master/LICENSE)
[](https://github.com/Konstantin8105/sparse/actions/workflows/codecov.yml)
[](https://godoc.org/github.com/Konstantin8105/sparse)
**This package based on program CSparse from [SuiteSparse 5.4.0](http://faculty.cse.tamu.edu/davis/SuiteSparse/)**
### Comparation with `gonum.mat.LU`
```cmd
go test -v -cpuprofile cpu.prof -memprofile mem.prof -coverprofile=coverage.out -run=BenchmarkLU -bench=BenchmarkLU -benchmem
```
```result
goos: linux
goarch: amd64
pkg: github.com/Konstantin8105/sparse
BenchmarkLU/Sparse:__30:__300-4 37153 30785 ns/op 51328 B/op 28 allocs/op
BenchmarkLU/Dense_:__30:__300-4 41449 29516 ns/op 9236 B/op 11 allocs/op
BenchmarkLU/Sparse:_100:_1070-4 9572 108839 ns/op 201328 B/op 28 allocs/op
BenchmarkLU/Dense_:_100:_1070-4 4323 233880 ns/op 85005 B/op 11 allocs/op
BenchmarkLU/Sparse:_300:_3270-4 3404 324523 ns/op 566384 B/op 28 allocs/op
BenchmarkLU/Dense_:_300:_3270-4 476 2494250 ns/op 739173 B/op 20 allocs/op
BenchmarkLU/Sparse:1000:10970-4 1029 1065713 ns/op 1794812 B/op 28 allocs/op
BenchmarkLU/Dense_:1000:10970-4 18 63434980 ns/op 8061283 B/op 47 allocs/op
BenchmarkLU/Sparse:3000:32970-4 378 3206861 ns/op 5382921 B/op 28 allocs/op
BenchmarkLU/Dense_:3000:32970-4 2 802618764 ns/op 72295580 B/op 111 allocs/op
```
Using sparse algorithm is effective in test case for square matrixes with size more 50.
### Example of comparing CSparse and CXSparse
```cmd
rm -rf /tmp/CXSparse
cp -R ./CXSparse/ /tmp/
sed -i 's/CS_ENTRY/double/g' /tmp/CXSparse/Source/*.c
sed -i 's/CS_INT/csi/g' /tmp/CXSparse/Source/*.c
meld /tmp/CXSparse/ ./CSparse/
```
### How updating package
* Check new version of `CSparse` is exist on [page](http://faculty.cse.tamu.edu/davis/SuiteSparse/).
* Download new version.
* Compare file-by-file with file in folder `CSparse` of that package.
* Inject changes into Go files of package.
> Note:
> CSparse haven`t any updates at the last few years, so
> that package is actual at the future.
>
### Just for information
**This package transpiled CSparse from C to Go by [c4go](https://github.com/Konstantin8105/c4go).**
### Profiling
```
go test -v -cpuprofile=cpu.prof -memprofile=mem.prof -run=Benchmark -bench=Benchmark -benchmem
go tool pprof cpu.prof
go tool pprof mem.prof
```
### Coverage
```
go test -coverprofile=coverage.out -run=TestLU
go tool cover -html=coverage.out
```
### Questions for CSparse
* Variables `css.lnz` and `css.unz` is not float type `double`, better to use integer type like `int`.
*