Spaces:
Running
Running
File size: 4,410 Bytes
78c921d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { Buffer } from './buffer.js';
import { Int } from './int.js';
import { SparseMatrixCompressedAxis } from './sparse-matrix-compressed-axis.js';
/**
* Compressed Sparse format, that is matrix-specific.
*/
export class SparseMatrixIndexCSX {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):SparseMatrixIndexCSX {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsSparseMatrixIndexCSX(bb:flatbuffers.ByteBuffer, obj?:SparseMatrixIndexCSX):SparseMatrixIndexCSX {
return (obj || new SparseMatrixIndexCSX()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsSparseMatrixIndexCSX(bb:flatbuffers.ByteBuffer, obj?:SparseMatrixIndexCSX):SparseMatrixIndexCSX {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new SparseMatrixIndexCSX()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
/**
* Which axis, row or column, is compressed
*/
compressedAxis():SparseMatrixCompressedAxis {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt16(this.bb_pos + offset) : SparseMatrixCompressedAxis.Row;
}
/**
* The type of values in indptrBuffer
*/
indptrType(obj?:Int):Int|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new Int()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}
/**
* indptrBuffer stores the location and size of indptr array that
* represents the range of the rows.
* The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data.
* The length of this array is 1 + (the number of rows), and the type
* of index value is long.
*
* For example, let X be the following 6x4 matrix:
* ```text
* X := [[0, 1, 2, 0],
* [0, 0, 3, 0],
* [0, 4, 0, 5],
* [0, 0, 0, 0],
* [6, 0, 7, 8],
* [0, 9, 0, 0]].
* ```
* The array of non-zero values in X is:
* ```text
* values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9].
* ```
* And the indptr of X is:
* ```text
* indptr(X) = [0, 2, 3, 5, 5, 8, 10].
* ```
*/
indptrBuffer(obj?:Buffer):Buffer|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? (obj || new Buffer()).__init(this.bb_pos + offset, this.bb!) : null;
}
/**
* The type of values in indicesBuffer
*/
indicesType(obj?:Int):Int|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? (obj || new Int()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}
/**
* indicesBuffer stores the location and size of the array that
* contains the column indices of the corresponding non-zero values.
* The type of index value is long.
*
* For example, the indices of the above X is:
* ```text
* indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1].
* ```
* Note that the indices are sorted in lexicographical order for each row.
*/
indicesBuffer(obj?:Buffer):Buffer|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? (obj || new Buffer()).__init(this.bb_pos + offset, this.bb!) : null;
}
static startSparseMatrixIndexCSX(builder:flatbuffers.Builder) {
builder.startObject(5);
}
static addCompressedAxis(builder:flatbuffers.Builder, compressedAxis:SparseMatrixCompressedAxis) {
builder.addFieldInt16(0, compressedAxis, SparseMatrixCompressedAxis.Row);
}
static addIndptrType(builder:flatbuffers.Builder, indptrTypeOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, indptrTypeOffset, 0);
}
static addIndptrBuffer(builder:flatbuffers.Builder, indptrBufferOffset:flatbuffers.Offset) {
builder.addFieldStruct(2, indptrBufferOffset, 0);
}
static addIndicesType(builder:flatbuffers.Builder, indicesTypeOffset:flatbuffers.Offset) {
builder.addFieldOffset(3, indicesTypeOffset, 0);
}
static addIndicesBuffer(builder:flatbuffers.Builder, indicesBufferOffset:flatbuffers.Offset) {
builder.addFieldStruct(4, indicesBufferOffset, 0);
}
static endSparseMatrixIndexCSX(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
builder.requiredField(offset, 6) // indptrType
builder.requiredField(offset, 8) // indptrBuffer
builder.requiredField(offset, 10) // indicesType
builder.requiredField(offset, 12) // indicesBuffer
return offset;
}
}
|