Socket
Socket
Sign inDemoInstall

simplicial-complex

Package Overview
Dependencies
2
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.2.0

2

package.json
{
"name": "simplicial-complex",
"version": "0.1.1",
"version": "0.2.0",
"description": "Topological indexing for simplicial complexes",

@@ -5,0 +5,0 @@ "main": "topology.js",

@@ -192,9 +192,8 @@ simplicial-complex

### `boundary(cells, n)`
Computes the <a href="http://en.wikipedia.org/wiki/Boundary_(topology)">d-dimensional boundary</a> of a cell complex. For example, in a triangular mesh `boundary(tris, 1)` gives an array of all the boundary edges of the mesh; or `boundary(tets, 2)` gives an array of all boundary faces. Algebraically, this is the same as evaluating the boundary operator in the Z/2 homology.
### `boundary(cells)`
Computes the <a href="http://en.wikipedia.org/wiki/Boundary_(topology)">d-dimensional boundary</a> of all cells, including duplicates.
* `cells` is a cell complex.
* `n` is the dimension of the boundary we are computing.
**Returns:** A `normalize`d array of `n`-dimensional cells representing the boundary of the cell complex.
**Returns:** An array of cells representing the boundary of the cell complex.

@@ -201,0 +200,0 @@ **Time complexity:** `O((d^n + log(cells.length)) * cells.length)`

@@ -224,4 +224,3 @@ var test = require("tap").test

var tetra = [[0,1,2,3]];
arr_equals(t,top.boundary(tetra,2), tris);
arr_equals(t,top.boundary(tris,1), []);
arr_equals(t,top.normalize(top.boundary(tetra,2)), tris);

@@ -228,0 +227,0 @@ t.end();

@@ -52,23 +52,21 @@ "use strict"; "use restrict";

case 2:
t = ((a[0]+a[1])&0xffffffff) - ((b[0]+b[1])&0xffffffff);
if(t) {
return t;
var d = a[0]+a[1]-b[0]-b[1];
if(d) {
return d;
}
return ((a[0]*a[1])&0xffffffff) - ((b[0]*b[1])&0xffffffff);
return Math.min(a[0],a[1]) - Math.min(b[0],b[1]);
case 3:
var l0 = (a[0]+a[1])&0xffffffff
, l2 = a[2]
, m0 = (b[0]+b[1])&0xffffffff
, m2 = b[2];
t = ((l2+l0)&0xffffffff) - ((m2+m0)&0xffffffff);
if(t) {
return t;
var l1 = a[0]+a[1]
, m1 = b[0]+b[1];
d = l1+a[2] - (m1+b[2]);
if(d) {
return d;
}
var l1 = (a[0]*a[1])&0xffffffff
, m1 = (b[0]*b[1])&0xffffffff;
t = ((l2*l1)&0xffffffff) - ((m2*m1)&0xffffffff);
if(t) {
return t;
var l0 = Math.min(a[0], a[1])
, m0 = Math.min(b[0], b[1])
, d = Math.min(l0, a[2]) - Math.min(m0, b[2]);
if(d) {
return d;
}
return (((l2*l0)&0xffffffff)+l1) - (((m2*m0)&0xffffffff)+m1);
return Math.min(l0+a[2], l1) - Math.min(m0+b[2], m1);

@@ -110,5 +108,6 @@ //TODO: Maybe optimize n=4 as well?

return cells
} else {
cells.sort(compareCells);
return cells;
}
cells.sort(compareCells);
return cells;
}

@@ -191,3 +190,3 @@ exports.normalize = normalize;

//Enumerates all of the n-cells of a cell complex (in more technical terms, the boundary operator with free coefficients)
function subcells(cells, n) {
function fullSkeleton(cells, n) {
if(n < 0) {

@@ -213,3 +212,3 @@ return [];

}
exports.subcells = subcells;
exports.fullSkeleton = fullSkeleton;

@@ -221,3 +220,3 @@ //Computes the n-skeleton of a cell complex (in other words, the n-boundary operator in the homology over the Boolean semiring)

}
var res = subcells(cells, n);
var res = fullSkeleton(cells, n);
normalize(res);

@@ -244,25 +243,17 @@ var ptr = 1;

//Computes the nth boundary operator
function boundary(cells, n) {
if(n < 0) {
return [];
}
var res = subcells(cells, n);
res.sort(compareCells);
var ptr = 0
, i = 0;
while(true) {
while(i < res.length-1 && compareCells(res[i], res[i+1]) === 0) {
i += 2;
//Computes the boundary of all cells, does not remove duplicates
function boundary(cells) {
var res = [];
for(var i=0; i<cells.length; ++i) {
var c = cells[i];
for(var j=0; j<c.length; ++j) {
var b = new Array(c.length-1);
for(var k=0, l=0; k<c.length; ++k) {
if(k !== j) {
b[l++] = c[k];
}
}
res.push(b);
}
if(i >= res.length) {
break;
}
var a = res[ptr++]
, b = res[i++];
for(var j=0; j<=n; ++j) {
a[j] = b[j];
}
}
res.length = ptr;
return res;

@@ -269,0 +260,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc