npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lapack

v0.1.0

Published

node-lapack ===========

Downloads

91

Readme

node-lapack

A node.js wrapper for the high-performance LAPACK linear algebra library.

Prerequisites

This library require LAPACK to be built and installed as a shared library. In time the entire build process may be unified into this project, but that's some time away.

In the meantime I've placed some basic LAPACK build instructions at the end of this document.

Installation

npm install lapack

Usage

var lapack = require('lapack');

/*
LAPACK functions
*/

var result = lapack.sgeqrf([
    [1, 2, 3],
    [3, 4, 5],
    [5, 6, 7]
]);

console.log(result.R);
console.log(result.tau);

result = sgesvd('A', 'A', [
    [1, 2, 3],
    [3, 4, 5],
    [5, 6, 7]
]);

console.log(result.U);
console.log(result.S);
console.log(result.VT);

result = lapack.sgetrf([
    [1, 2, 3],
    [3, 4, 5],
    [5, 6, 7]
]);

console.log(result.LU);
console.log(result.IPIV);

/*
conveniently wrapped processes
*/

// perform a complete LU factorization
var lu = lapack.lu([
    [1, 2, 3],
    [3, 4, 5],
    [5, 6, 7]
]);

console.log(lu.L);
console.log(lu.U);
console.log(lu.P);


// perform a complete QR factorization
var qr = lapack.qr([
    [1, 2, 3],
    [3, 4, 5],
    [5, 6, 7]
]);

console.log(qr.Q);
console.log(qr.R);

// solve a system of linear equations

var a = [
	[2, 4],
	[2, 8]];

var b = [[2], 
	[4]];

var result = lapack.sgesv(a, b);
console.log(result.X);
console.log(result.P);

LAPACK Building

These instructions are raw and a work in progress, but should work fine for linux and MacOS. The net result will be LAPACK and BLAS shared libraries.

If you haven't done so already download the LAPACK source http://www.netlib.org/lapack/

After unpacking the source create a make.inc based on the make.inc.example provided. For the purposes of this document I'll assume you have the "gfortran" fortran compiler installed.

Then make the following changes:

make.inc

CHANGE:

FORTRAN  = gfortran
OPTS     = -O2
DRVOPTS  = $(OPTS)
NOOPT    = -O0
LOADER   = gfortran
LOADOPTS =

TO:

UNAME := $(shell uname)

FORTRAN  = gfortran
OPTS     = -O2 -fPIC
DRVOPTS  = $(OPTS)
NOOPT    = -O0 -fPIC
LOADER   = gfortran
LOADOPTS =

ifeq ($(UNAME), Darwin)
LIBEXT=dylib
else
LIBEXT=so
endif

BLAS/SRC/Makefile

CHANGE:

all: $(BLASLIB)

TO:

all: $(BLASLIB) libblas.$(LIBEXT)

libblas.$(LIBEXT):
    $(FORTRAN) -shared -o $@ *.o
    cp $@ ../../$@

CHANGE:

clean:
    rm -f *.o

TO:

clean:
    rm -f *.o
    rm -f *.a
    rm -f *.$(LIBEXT)

SRC/Makefile

CHANGE:

all: ../$(LAPACKLIB)

TO:

all: ../$(LAPACKLIB) liblapack.$(LIBEXT)

liblapack.$(LIBEXT):
    gfortran -shared -o $@ $(ALLOBJ) -lblas -L..
    cp $@ ../$@

CHANGE:

clean:
    rm -f *.o

TO:

clean:
    rm -f *.o
    rm -f *.a
    rm -f *.$(LIBEXT)

Compiling

make blaslib
make lapacklib

Installing

# for linux
cp liblapack.so libblas.so /usr/lib
# for macos
# NOTE! this might be dangerous now. macs ship with liblapack.dylib now?
# regardless, i don't suggest installing a custom lapack right now on Mac
cp liblapack.dylib libblas.dylib /usr/lib

License

Copyright (c) 2011, Chris Umbel

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.