1 declare namespace liba {
3 * square root of an unsigned integer
4 * @param x independent variable
5 * @return calculated result
7 function isqrt(x: number): number;
9 * reciprocal of square-root
10 * @param x independent variable
11 * @return calculated result
13 function rsqrt(x: number): number;
15 * a hash function whose prime number is 131
16 * @param block block to be processed
17 * @param value initial value
20 function hash_bkdr(block: string, value: number): number;
22 * a hash function whose prime number is 65599
23 * @param block block to be processed
24 * @param value initial value
27 function hash_sdbm(block: string, value: number): number;
30 /** Cyclic Redundancy Check comparison table */
31 readonly table: Uint8Array;
33 * generate for 8-bit Cyclic Redundancy Check
34 * @param poly polynomial that is CRC's divisor
35 * @param reversed is reversed?
37 gen(poly: number, reversed?: boolean): crc8;
39 * calculate for 8-bit Cyclic Redundancy Check
40 * @param block block to be processed
41 * @param value initial value
42 * @return output value
44 eval(block: string, value: number): number;
46 * pack a block and its CRC-8 value
47 * @param block block to be processed
48 * @param value initial value
49 * @return packed block
51 pack(block: string, value: number): Uint8Array;
54 /** constructor for 8-bit Cyclic Redundancy Check */
57 * @param poly polynomial that is CRC's divisor
58 * @param reversed is reversed?
60 new(poly: number, reversed?: boolean): crc8;
61 readonly prototype: crc8;
65 /** Cyclic Redundancy Check comparison table */
66 readonly table: Uint16Array;
68 * generate for 16-bit Cyclic Redundancy Check
69 * @param poly polynomial that is CRC's divisor
70 * @param reversed is reversed?
72 gen(poly: number, reversed?: boolean): crc16;
74 * calculate for 16-bit Cyclic Redundancy Check
75 * @param block block to be processed
76 * @param value initial value
77 * @return output value
79 eval(block: string, value: number): number;
81 * pack a block and its CRC-16 value
82 * @param block block to be processed
83 * @param value initial value
84 * @return packed block
86 pack(block: string, value: number): Uint8Array;
89 /** constructor for 16-bit Cyclic Redundancy Check */
92 * @param poly polynomial that is CRC's divisor
93 * @param reversed is reversed?
95 new(poly: number, reversed?: boolean): crc16;
96 readonly prototype: crc16;
100 /** Cyclic Redundancy Check comparison table */
101 readonly table: Uint32Array;
103 * generate for 32-bit Cyclic Redundancy Check
104 * @param poly polynomial that is CRC's divisor
105 * @param reversed is reversed?
107 gen(poly: number, reversed?: boolean): crc32;
109 * calculate for 32-bit Cyclic Redundancy Check
110 * @param block block to be processed
111 * @param value initial value
112 * @return output value
114 eval(block: string, value: number): number;
116 * pack a block and its CRC-32 value
117 * @param block block to be processed
118 * @param value initial value
119 * @return packed block
121 pack(block: string, value: number): Uint8Array;
124 /** constructor for 32-bit Cyclic Redundancy Check */
127 * @param poly polynomial that is CRC's divisor
128 * @param reversed is reversed?
130 new(poly: number, reversed?: boolean): crc32;
131 readonly prototype: crc32;
135 /** Cyclic Redundancy Check comparison table */
136 readonly table: BigUint64Array;
138 * generate for 64-bit Cyclic Redundancy Check
139 * @param poly polynomial that is CRC's divisor
140 * @param reversed is reversed?
142 gen(poly: bigint, reversed?: boolean): crc64;
144 * calculate for 64-bit Cyclic Redundancy Check
145 * @param block block to be processed
146 * @param value initial value
147 * @return output value
149 eval(block: string, value: bigint): bigint;
151 * pack a block and its CRC-64 value
152 * @param block block to be processed
153 * @param value initial value
154 * @return packed block
156 pack(block: string, value: number): Uint8Array;
159 /** constructor for 64-bit Cyclic Redundancy Check */
162 * @param poly polynomial that is CRC's divisor
163 * @param reversed is reversed?
165 new(poly: bigint, reversed?: boolean): crc64;
166 readonly prototype: crc64;
170 /** filter coefficient [0,1] */
171 readonly alpha: number;
173 readonly output: number;
175 readonly input: number;
177 * generate for High Pass Filter
178 * @param fc cut-off frequency unit(hz)
179 * @param ts sampling time unit(s)
181 gen(fc: number, ts: number): hpf;
183 * calculate for High Pass Filter
184 * @param x input value
185 * @return output value
187 iter(x: number): number;
188 /** zeroing for High Pass Filter */
192 /** constructor for High Pass Filter */
195 * @param fc cut-off frequency unit(hz)
196 * @param ts sampling time unit(s)
198 new(fc: number, ts: number): hpf;
200 * @param alpha filter coefficient [0,1]
202 new(alpha: number): hpf;
203 readonly prototype: hpf;
207 /** filter coefficient [0,1] */
208 readonly alpha: number;
210 readonly output: number;
212 * generate for Low Pass Filter
213 * @param fc cut-off frequency unit(hz)
214 * @param ts sampling time unit(s)
216 gen(fc: number, ts: number): lpf;
218 * calculate for Low Pass Filter
219 * @param x input value
220 * @return output value
222 iter(x: number): number;
223 /** zeroing for Low Pass Filter */
227 /** constructor for Low Pass Filter */
230 * @param fc cut-off frequency unit(hz)
231 * @param ts sampling time unit(s)
233 new(fc: number, ts: number): lpf;
235 * @param alpha filter coefficient [0,1]
237 new(alpha: number): lpf;
238 readonly prototype: lpf;
241 /** membership function */
245 /** gaussian membership function */
247 /** gaussian combination membership function */
249 /** generalized bell-shaped membership function */
251 /** sigmoidal membership function */
253 /** difference between two sigmoidal membership functions */
255 /** product of two sigmoidal membership functions */
257 /** trapezoidal membership function */
259 /** triangular membership function */
261 /** linear s-shaped saturation membership function */
263 /** linear z-shaped saturation membership function */
265 /** s-shaped membership function */
267 /** z-shaped membership function */
269 /** pi-shaped membership function */
272 * gaussian membership function
273 * @param x input value for which to compute membership value.
274 * @param sigma is the standard deviation.
275 * @param c is the mean.
276 * @return membership value.
278 gauss(x: number, sigma: number, c: number): number;
280 * gaussian combination membership function
281 * @param x input value for which to compute membership value.
282 * @param sigma1 is the standard deviation of the left gaussian function.
283 * @param c1 is the mean of the left gaussian function.
284 * @param sigma2 is the standard deviation of the right gaussian function.
285 * @param c2 is the mean of the right gaussian function.
286 * @return membership value.
288 gauss2(x: number, sigma1: number, c1: number, sigma2: number, c2: number): number;
290 * generalized bell-shaped membership function
291 * @param x input value for which to compute membership value.
292 * @param a defines the width of the membership function, where a larger value creates a wider membership function.
293 * @param b defines the shape of the curve on either side of the central plateau, where a larger value creates a more steep transition.
294 * @param c defines the center of the membership function.
295 * @return membership value.
297 gbell(x: number, a: number, b: number, c: number): number;
299 * sigmoidal membership function
300 * @param x input value for which to compute membership value.
301 * @param a defines the width of the transition area.
302 * @param c defines the center of the transition area.
303 * @return membership value.
305 sig(x: number, a: number, c: number): number;
307 * difference between two sigmoidal membership functions
308 * @param x input value for which to compute membership value.
309 * @param a1 defines the width of the first transition area.
310 * @param c1 defines the center of the first transition area.
311 * @param a2 defines the width of the second transition area.
312 * @param c2 defines the center of the second transition area.
313 * @return membership value.
315 dsig(x: number, a1: number, c1: number, a2: number, c2: number): number;
317 * product of two sigmoidal membership functions
318 * @param x input value for which to compute membership value.
319 * @param a1 defines the width of the first transition area.
320 * @param c1 defines the center of the first transition area.
321 * @param a2 defines the width of the second transition area.
322 * @param c2 defines the center of the second transition area.
323 * @return membership value.
325 psig(x: number, a1: number, c1: number, a2: number, c2: number): number;
327 * trapezoidal membership function
328 * @param x input value for which to compute membership value.
329 * @param a defines its left foot.
330 * @param b defines its left shoulder.
331 * @param c defines its right shoulder.
332 * @param d defines its right foot.
333 * @return membership value.
335 trap(x: number, a: number, b: number, c: number, d: number): number;
337 * triangular membership function
338 * @param x input value for which to compute membership value.
339 * @param a defines its left foot.
340 * @param b defines its peak.
341 * @param c defines its right foot.
342 * @return membership value.
344 tri(x: number, a: number, b: number, c: number): number;
346 * linear s-shaped saturation membership function
347 * @param x input value for which to compute membership value.
348 * @param a defines its foot.
349 * @param b defines its shoulder.
350 * @return membership value.
352 lins(x: number, a: number, b: number): number;
354 * linear z-shaped saturation membership function
355 * @param x input value for which to compute membership value.
356 * @param a defines its shoulder.
357 * @param b defines its foot.
358 * @return membership value.
360 linz(x: number, a: number, b: number): number;
362 * s-shaped membership function
363 * @param x input value for which to compute membership value.
364 * @param a defines its foot.
365 * @param b defines its shoulder.
366 * @return membership value.
368 s(x: number, a: number, b: number): number;
370 * z-shaped membership function
371 * @param x input value for which to compute membership value.
372 * @param a defines its shoulder.
373 * @param b defines its foot.
374 * @return membership value.
376 z(x: number, a: number, b: number): number;
378 * pi-shaped membership function
379 * @param x input value for which to compute membership value.
380 * @param a defines its left foot.
381 * @param b defines its left shoulder.
382 * @param c defines its right shoulder.
383 * @param d defines its right foot.
384 * @return membership value.
386 pi(x: number, a: number, b: number, c: number, d: number): number;
390 /** proportional constant */
392 /** integral constant */
394 /** derivative constant */
396 /** maximum integral output */
398 /** minimum integral output */
400 /** controller integral output */
401 readonly sum: number;
402 /** maximum final output */
404 /** minimum final output */
406 /** controller final output */
407 readonly out: number;
408 /** cache feedback */
409 readonly fdb: number;
411 readonly err: number;
413 * set proportional integral derivative constant for PID controller
414 * @param kp proportional constant
415 * @param ki integral constant
416 * @param kd derivative constant
418 kpid(kp: number, ki: number, kd: number): pid;
420 * calculate for PID controller
421 * @param set setpoint value
422 * @param fdb feedback value
423 * @return setpoint value
425 run(set: number, fdb: number): number;
427 * calculate for positional PID controller
428 * @param set setpoint value
429 * @param fdb feedback value
430 * @return output value
432 pos(set: number, fdb: number): number;
434 * calculate for incremental PID controller
435 * @param set setpoint value
436 * @param fdb feedback value
437 * @return output value
439 inc(set: number, fdb: number): number;
440 /** zeroing for PID controller */
444 /** constructor for proportional integral derivative controller */
447 readonly prototype: pid;
450 interface pid_fuzzy {
451 /** proportional constant */
453 /** integral constant */
455 /** derivative constant */
457 /** maximum integral output */
459 /** minimum integral output */
461 /** controller integral output */
462 readonly sum: number;
463 /** maximum final output */
465 /** minimum final output */
467 /** controller final output */
468 readonly out: number;
469 /** cache feedback */
470 readonly fdb: number;
472 readonly err: number;
473 /** number of order in the square matrix */
474 readonly order: number;
475 /** maximum number triggered by the rule */
478 * set fuzzy relational operator for fuzzy PID controller
479 * @param op enumeration for fuzzy PID controller operator
481 op(op: number): pid_fuzzy;
483 * set rule base for fuzzy PID controller
484 * @param me e's membership function parameter table
485 * @param mec ec's membership function parameter table
486 * @param mkp Kp's rule base table which must be a square matrix
487 * @param mki Ki's rule base table which must be a square matrix
488 * @param mkd Kd's rule base table which must be a square matrix
490 rule(me: number[][], mec: number[][], mkp: number[][], mki: number[][], mkd: number[][]): pid_fuzzy;
492 * set memory block for fuzzy PID controller
493 * @param num the maximum number triggered by the rule
495 set_block(num: number): pid_fuzzy;
497 * set proportional integral derivative constant for fuzzy PID controller
498 * @param kp proportional learning constant
499 * @param ki integral learning constant
500 * @param kd derivative learning constant
502 kpid(kp: number, ki: number, kd: number): pid_fuzzy;
504 * calculate for fuzzy PID controller
505 * @param set setpoint value
506 * @param fdb feedback value
507 * @return setpoint value
509 run(set: number, fdb: number): number;
511 * calculate for positional fuzzy PID controller
512 * @param set setpoint value
513 * @param fdb feedback value
514 * @return output value
516 pos(set: number, fdb: number): number;
518 * calculate for incremental fuzzy PID controller
519 * @param set setpoint value
520 * @param fdb feedback value
521 * @return output value
523 inc(set: number, fdb: number): number;
524 /** zeroing for fuzzy PID controller */
528 /** constructor for fuzzy PID controller */
543 /** sqrt(a,b)*sqrt(1-(1-a)*(1-b)) */
545 readonly prototype: pid_fuzzy;
548 interface pid_neuro {
549 /** proportional output coefficient */
551 /** proportional learning constant */
553 /** integral learning constant */
555 /** derivative learning constant */
557 /** proportional weight */
559 /** integral weight */
561 /** derivative weight */
563 /** maximum final output */
565 /** minimum final output */
567 /** controller final output */
568 readonly out: number;
569 /** cache feedback */
570 readonly fdb: number;
572 readonly err: number;
576 * set proportional integral derivative constant for single neuron PID controller
577 * @param k proportional output coefficient
578 * @param kp proportional learning constant
579 * @param ki integral learning constant
580 * @param kd derivative learning constant
582 kpid(k: number, kp: number, ki: number, kd: number): pid_neuro;
584 * set proportional integral derivative weight for single neuron PID controller
585 * @param wp proportional weight
586 * @param wi integral weight
587 * @param wd derivative weight
589 wpid(wp: number, wi: number, wd: number): pid_neuro;
591 * calculate for single neuron PID controller
592 * @param set setpoint value
593 * @param fdb feedback value
594 * @return setpoint value
596 run(set: number, fdb: number): number;
598 * calculate for incremental single neuron PID controller
599 * @param set setpoint value
600 * @param fdb feedback value
601 * @return output value
603 inc(set: number, fdb: number): number;
604 /** zeroing for single neuron PID controller */
608 /** constructor for single neuron PID controller */
611 readonly prototype: pid_neuro;
615 /** input for transfer function */
616 readonly input: Float64Array | Float32Array;
617 /** output for transfer function */
618 readonly output: Float64Array | Float32Array;
619 /** numerator for transfer function */
620 num: Float64Array | Float32Array;
621 /** denominator for transfer function */
622 den: Float64Array | Float32Array;
624 * set numerator for transfer function
625 * @param num numerator
627 set_num(num: number[]): tf;
629 * set denominator for transfer function
630 * @param den denominator
632 set_den(den: number[]): tf;
634 * calculate for transfer function
635 * @param x controller output
637 iter(x: number): number;
638 /** zeroing for transfer function */
642 /** constructor for transfer function */
645 * @param num numerator
646 * @param den denominator
648 new(num: number[], den: number[]): tf;
649 readonly prototype: tf;
653 /** total duration */
655 /** constant velocity phase */
657 /** acceleration phase */
659 /** deceleration phase */
661 /** time-interval in which the jerk is constant (j max or j min ) during the acceleration phase */
662 readonly taj: number;
663 /** time-interval in which the jerk is constant (j max or j min ) during the deceleration phase */
664 readonly tdj: number;
665 /** initial position */
667 /** final position */
669 /** initial velocity */
671 /** final velocity */
673 /** maximum velocity */
677 /** maximum acceleration */
679 /** maximum deceleration */
682 * @param jm defines the maximum jerk during system operation
683 * @param am defines the maximum acceleration during system operation
684 * @param vm defines the maximum velocity during system operation
685 * @param p0 defines the initial position
686 * @param p1 defines the final position
687 * @param v0 defines the initial velocity
688 * @param v1 defines the final velocity
689 * @return total duration
691 gen(jm: number, am: number, vm: number, p0: number, p1: number, v0: number, v1: number): number;
693 * calculate position for bell-shaped velocity trajectory
694 * @param dt difference between current time and initial time
696 pos(dt: number): number;
698 * calculate velocity for bell-shaped velocity trajectory
699 * @param dt difference between current time and initial time
701 vel(dt: number): number;
703 * calculate acceleration for bell-shaped velocity trajectory
704 * @param dt difference between current time and initial time
706 acc(dt: number): number;
708 * calculate jerk for bell-shaped velocity trajectory
709 * @param dt difference between current time and initial time
711 jer(dt: number): number;
714 /** constructor for bell-shaped velocity trajectory */
717 readonly prototype: trajbell;
720 interface trajpoly3 {
721 /** coefficients of position */
722 readonly p: Float64Array | Float32Array;
723 /** coefficients of velocity */
724 readonly v: Float64Array | Float32Array;
725 /** coefficients of acceleration */
726 readonly a: Float64Array | Float32Array;
728 * calculate position for cubic polynomial trajectory
729 * @param dt difference between current time and initial time
731 pos(dt: number): number;
733 * calculate velocity for cubic polynomial trajectory
734 * @param dt difference between current time and initial time
736 vel(dt: number): number;
738 * calculate acceleration for cubic polynomial trajectory
739 * @param dt difference between current time and initial time
741 acc(dt: number): number;
744 /** constructor for cubic polynomial trajectory */
747 * @param ts difference between final time and initial time
748 * @param p0 initial position
749 * @param p1 final position
751 new(ts: number, p0: number, p1: number): trajpoly3;
753 * @param ts difference between final time and initial time
754 * @param p0 initial position
755 * @param p1 final position
756 * @param v0 initial velocity
757 * @param v1 final velocity
759 new(ts: number, p0: number, p1: number, v0: number, v1: number): trajpoly3;
760 readonly prototype: trajpoly3;
763 interface trajpoly5 {
764 /** coefficients of position */
765 readonly p: Float64Array | Float32Array;
766 /** coefficients of velocity */
767 readonly v: Float64Array | Float32Array;
768 /** coefficients of acceleration */
769 readonly a: Float64Array | Float32Array;
771 * calculate position for quintic polynomial trajectory
772 * @param dt difference between current time and initial time
774 pos(dt: number): number;
776 * calculate velocity for quintic polynomial trajectory
777 * @param dt difference between current time and initial time
779 vel(dt: number): number;
781 * calculate acceleration for quintic polynomial trajectory
782 * @param dt difference between current time and initial time
784 acc(dt: number): number;
787 /** constructor for quintic polynomial trajectory */
790 * @param ts difference between final time and initial time
791 * @param p0 initial position
792 * @param p1 final position
794 new(ts: number, p0: number, p1: number): trajpoly5;
796 * @param ts difference between final time and initial time
797 * @param p0 initial position
798 * @param p1 final position
799 * @param v0 initial velocity
800 * @param v1 final velocity
802 new(ts: number, p0: number, p1: number, v0: number, v1: number): trajpoly5;
804 * @param ts difference between final time and initial time
805 * @param p0 initial position
806 * @param p1 final position
807 * @param v0 initial velocity
808 * @param v1 final velocity
809 * @param a0 initial acceleration
810 * @param a1 final acceleration
812 new(ts: number, p0: number, p1: number, v0: number, v1: number, a0: number, a1: number): trajpoly5;
813 readonly prototype: trajpoly5;
816 interface trajpoly7 {
817 /** coefficients of position */
818 readonly p: Float64Array | Float32Array;
819 /** coefficients of velocity */
820 readonly v: Float64Array | Float32Array;
821 /** coefficients of acceleration */
822 readonly a: Float64Array | Float32Array;
823 /** coefficients of jerk */
824 readonly j: Float64Array | Float32Array;
826 * calculate position for hepta polynomial trajectory
827 * @param dt difference between current time and initial time
829 pos(dt: number): number;
831 * calculate velocity for hepta polynomial trajectory
832 * @param dt difference between current time and initial time
834 vel(dt: number): number;
836 * calculate acceleration for hepta polynomial trajectory
837 * @param dt difference between current time and initial time
839 acc(dt: number): number;
841 * calculate jerk for hepta polynomial trajectory
842 * @param dt difference between current time and initial time
844 jer(dt: number): number;
847 /** constructor for hepta polynomial trajectory */
850 * @param ts difference between final time and initial time
851 * @param p0 initial position
852 * @param p1 final position
854 new(ts: number, p0: number, p1: number): trajpoly7;
856 * @param ts difference between final time and initial time
857 * @param p0 initial position
858 * @param p1 final position
859 * @param v0 initial velocity
860 * @param v1 final velocity
862 new(ts: number, p0: number, p1: number, v0: number, v1: number): trajpoly7;
864 * @param ts difference between final time and initial time
865 * @param p0 initial position
866 * @param p1 final position
867 * @param v0 initial velocity
868 * @param v1 final velocity
869 * @param a0 initial acceleration
870 * @param a1 final acceleration
872 new(ts: number, p0: number, p1: number, v0: number, v1: number, a0: number, a1: number): trajpoly7;
874 * @param ts difference between final time and initial time
875 * @param p0 initial position
876 * @param p1 final position
877 * @param v0 initial velocity
878 * @param v1 final velocity
879 * @param a0 initial acceleration
880 * @param a1 final acceleration
881 * @param j0 initial jerk
882 * @param j1 final jerk
884 new(ts: number, p0: number, p1: number, v0: number, v1: number, a0: number, a1: number, j0: number, j1: number): trajpoly7;
885 readonly prototype: trajpoly7;
889 /** total duration */
891 /** initial position */
893 /** final position */
895 /** initial velocity */
897 /** final velocity */
899 /** constant velocity */
901 /** time before constant velocity */
903 /** time after constant velocity */
905 /** position before constant velocity */
907 /** position after constant velocity */
909 /** acceleration before constant velocity */
911 /** acceleration after constant velocity */
914 * @param vm defines the maximum velocity during system operation
915 * @param ac defines the acceleration before constant velocity
916 * @param de defines the acceleration after constant velocity
917 * @param p0 defines the initial position
918 * @param p1 defines the final position
919 * @param v0 defines the initial velocity
920 * @param v1 defines the final velocity
921 * @return total duration
923 gen(vm: number, ac: number, de: number, p0: number, p1: number, v0: number, v1: number): number;
925 * calculate position for trapezoidal velocity trajectory
926 * @param dt difference between current time and initial time
928 pos(dt: number): number;
930 * calculate velocity for trapezoidal velocity trajectory
931 * @param dt difference between current time and initial time
933 vel(dt: number): number;
935 * calculate acceleration for trapezoidal velocity trajectory
936 * @param dt difference between current time and initial time
938 acc(dt: number): number;
941 /** constructor for trapezoidal velocity trajectory */
944 readonly prototype: trajtrap;
959 * parse for version string
960 * @param ver version string to be parsed
962 parse(ver: string): version;
964 * compare this version with that version
965 * @param ver version to be compared
967 cmp(ver: version): number;
969 * this version is less than that version
970 * @param ver version to be compared
972 lt(ver: version): boolean;
974 * this version is greater than that version
975 * @param ver version to be compared
977 gt(ver: version): boolean;
979 * this version is less than or equal to that version
980 * @param ver version to be compared
982 le(ver: version): boolean;
984 * this version is greater than or equal to that version
985 * @param ver version to be compared
987 ge(ver: version): boolean;
989 * this version is equal to that version
990 * @param ver version to be compared
992 eq(ver: version): boolean;
994 * this version is not equal to that version
995 * @param ver version to be compared
997 ne(ver: version): boolean;
998 /** return string representation of version */
1002 /** constructor for version */
1005 * @param major major number
1006 * @param minor minor number
1007 * @param third third number
1008 * @param extra extra number
1010 new(major?: number, minor?: number, third?: number, extra?: number): version;
1012 * algorithm library version check
1013 * @param major required major number
1014 * @param minor required minor number
1015 * @param patch required patch number
1016 * @returns -3(<major),-2(<minor),-1(<patch),0,+1(>patch),+2(>minor),+3(>major)
1018 check(major: number, minor: number, patch: number): number;
1019 /** algorithm library version major */
1021 /** algorithm library version minor */
1023 /** algorithm library version patch */
1025 /** algorithm library version tweak */
1027 readonly prototype: version;
1030 /** algorithm library version string */
1031 const VERSION: string;