Skip to content

Commit 273c560

Browse files
committed
first
0 parents  commit 273c560

49 files changed

Lines changed: 6033 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"C_Cpp.errorSquiggles": "disabled",
3+
"files.associations": {
4+
"*.embeddedhtml": "html",
5+
"ratio": "cpp"
6+
}
7+
}

index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const simplecalc = require("./스크립트/단순한/단순한")
2+
const rootscalculator = require('./스크립트/2차/2차')
3+
4+
5+
exports.roots = function (a, b, c) {
6+
return rootscalculator.roots(a, b, c)
7+
}
8+
9+
exports.printMsg = function () {
10+
console.log("This is a message from the demo package");
11+
}
12+
exports.add = function (item1, item2) {
13+
return simplecalc.add(item1, item2)
14+
}
15+
16+
exports.sub = function (item1, item2) {
17+
return simplecalc.substract(item1, item2)
18+
}
19+
20+
exports.div = function (item1, item2) {
21+
return simplecalc.divide(item1, item2)
22+
}
23+
24+
exports.mul = function (item1, item2) {
25+
return simplecalc.multiply(item1, item2)
26+
}
27+

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "entitytocode",
3+
"version": "2.3.2",
4+
"description": "An npm library with physics and mathematical methods backed by c++",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "Gavin",
10+
"license": "ISC",
11+
"dependencies": {
12+
"nan": "^2.18.0",
13+
"node-gyp": "^10.0.1"
14+
}
15+
}

readme.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<h1>Entity to code </h1>
2+
3+
Version | 1.0.0 | 2.0.0 | 2.1.0 | 2.2.0 | 2.3.0 | 2.3.1
4+
--- | --- | --- | --- |--- |--- |---
5+
Stable | Yes | No | No | Yes | Yes | Yes
6+
7+
<h2>New feats</h2>
8+
<h3>2.3.2 (patch)</h3>
9+
<p><b>readme fix</b></p>
10+
<h3>2.3.1 (patch)</h3>
11+
<p><b>Quadratic Roots function Availible</b></p>
12+
<h3>2.3.0 (patch)</h3>
13+
<p><b>HALTED</b></p>
14+
<h3>2.2.3 (patch)</h3>
15+
<p>Readme update</p>
16+
<h3>2.2.2 (patch)</h3>
17+
<p>Readme update</p>
18+
<h3>2.2.1 (patch)</h3>
19+
<p>Readme update</p>
20+
<h3>2.2.0</h3>
21+
<p>successful model with c++ integration</p>
22+
<h3>2.1.0</h3>
23+
<p>Buggy prototype with c++ integration</p>
24+
<h3>2.0.0</h3>
25+
<p>Faulty prototype with c++ integration</p>
26+
<h3>1.0.0</h3>
27+
<p>Simple string msg</p>
28+
29+
<h2>About</h2>
30+
<p>A mathematical library for various different mathematical functions (prod) backed by c++ (node-gyp/nan)</p>
31+
<h2>Installation</h2>
32+
33+
npm i entitytocode
34+
35+
<h2>printMsg</h2>
36+
<p>Versions: <b>1.0.0 + </b></p>
37+
<p>Usage (nodeJS): </p>
38+
39+
const package = require('entitytocode')
40+
package.printMsg();
41+
<p>Output:</p>
42+
43+
This is a message from the demo package
44+
45+
<h2>add</h2>
46+
<p>Versions: <b>2.0.0 + </b></p>
47+
<p>Disclaimer: Not stable in versions 2.0.0 - 2.1.0 </p>
48+
<p>Types for parameters: Item1 = Int, Item2 = Int</p>
49+
<p>Example (nodeJS): </p>
50+
51+
const package = require('entitytocode')
52+
const X = package.add(1, 2)
53+
console.log(X)
54+
<p>Output:</p>
55+
56+
3
57+
58+
<h2>Sub</h2>
59+
<p>Versions: <b>2.0.0 + </b></p>
60+
<p>Disclaimer: Not stable in versions 2.0.0 - 2.1.0 </p>
61+
<p>Types for parameters: Item1 = Int, Item2 = Int</p>
62+
<p>Example (nodeJS): </p>
63+
64+
const package = require('entitytocode')
65+
const X = package.sub(-1, 2)
66+
console.log(X)
67+
68+
<p>output:</p>
69+
70+
-3
71+
72+
<h2>Mul</h2>
73+
<p>Versions: <b>2.0.0 + </b></p>
74+
<p>Disclaimer: Not stable in versions 2.0.0 - 2.1.0 </p>
75+
<p>Types for parameters: Item1 = Int, Item2 = Int</p>
76+
<p>Example (nodeJS): </p>
77+
78+
const package = require('entitytocode')
79+
const X = package.mul(-3.2, 2.3)
80+
console.log(X)
81+
82+
<p>output:</p>
83+
84+
-7.359999999999999
85+
86+
87+
<h2>Div</h2>
88+
<p>Versions: <b>2.0.0 + </b></p>
89+
<p>Disclaimer: Not stable in versions 2.0.0 - 2.1.0 </p>
90+
<p>Types for parameters: Item1 = Int, Item2 = Int</p>
91+
<p>Example (nodeJS): </p>
92+
93+
const package = require('entitytocode')
94+
const X = package.div(-1.5, 2)
95+
console.log(X)
96+
97+
<p>output:</p>
98+
99+
-0.75
100+
101+
102+
<h2>Quadratic Roots</h2>
103+
<p>Versions: <b>2.3.1 + </b></p>
104+
<p>Types for parameters: A = Int, B = Int, C = Int</p>
105+
<p>Output: It returns an array with 3 values, <br/>
106+
1: number of roots: If there are No roots then it will return 0, if there are one, then 1, if there are two then 2. <br/>
107+
2 & 3: roots: In the calculation, two roots are returned, These are them, if there are only one root, both will be identical, and if there are none, item 1 will be 0 and it will return the imaginary roots</p>
108+
<p>Example (nodeJS): </p>
109+
110+
const moduleQRoots = require('entitytocode')
111+
112+
let NoRealRoots = moduleQRoots.roots(1, 2, 3)
113+
console.info('::::::::::::::::::::::::NO REAL ROOTS::::::::::::::::::::::::')
114+
console.log(NoRealRoots);
115+
console.log('1X^2 + 2X + 3')
116+
let OneRealRoot = moduleQRoots.roots(1, 2, 1)
117+
console.info('::::::::::::::::::::::::ONE REAL ROOTS::::::::::::::::::::::::')
118+
console.log(OneRealRoot);
119+
console.log('1X^2 + 2X + 1')
120+
let TworealRoots = moduleQRoots.roots(1, 3, 1)
121+
console.info('::::::::::::::::::::::::TWO REAL ROOTS::::::::::::::::::::::::')
122+
console.log(TworealRoots);
123+
console.log('1X^2 + 3X + 1')
124+
125+
<p>output:</p>
126+
127+
::::::::::::::::::::::::NO REAL ROOTS::::::::::::::::::::::::
128+
[ 0, 0.41421356237309515, -2.414213562373095 ]
129+
1X^2 + 2X + 3
130+
::::::::::::::::::::::::ONE REAL ROOTS::::::::::::::::::::::::
131+
[ 1, -1, -1 ]
132+
1X^2 + 2X + 1
133+
::::::::::::::::::::::::NO REAL ROOTS::::::::::::::::::::::::
134+
[ 2, -0.3819660112501051, -2.618033988749895 ]
135+
1X^2 + 3X + 1

스크립트/2차/2-test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// const moduleQRoots = require('../2차/2차')
2+
3+
// let NoRealRoots = moduleQRoots.roots(1, 2, 3)
4+
// console.info('::::::::::::::::::::::::NO REAL ROOTS::::::::::::::::::::::::')
5+
// console.log(NoRealRoots);
6+
// console.log('1X^2 + 2X + 3')
7+
// let OneRealRoot = moduleQRoots.roots(1, 2, 1)
8+
// console.info('::::::::::::::::::::::::ONE REAL ROOTS::::::::::::::::::::::::')
9+
// console.log(OneRealRoot );
10+
// console.log('1X^2 + 2X + 1')
11+
// let TworealRoots = moduleQRoots.roots(1, 3, 1)
12+
// console.info('::::::::::::::::::::::::NO REAL ROOTS::::::::::::::::::::::::')
13+
// console.log(TworealRoots );
14+
// console.log('1X^2 + 3X + 1')
15+
16+
17+
const moduleQRoots = require('entitytocode')
18+
19+
let NoRealRoots = moduleQRoots.roots(1, 2, 3)
20+
console.info('::::::::::::::::::::::::NO REAL ROOTS::::::::::::::::::::::::')
21+
console.log(NoRealRoots);
22+
console.log('1X^2 + 2X + 3')
23+
let OneRealRoot = moduleQRoots.roots(1, 2, 1)
24+
console.info('::::::::::::::::::::::::ONE REAL ROOTS::::::::::::::::::::::::')
25+
console.log(OneRealRoot);
26+
console.log('1X^2 + 2X + 1')
27+
let TworealRoots = moduleQRoots.roots(1, 3, 1)
28+
console.info('::::::::::::::::::::::::NO REAL ROOTS::::::::::::::::::::::::')
29+
console.log(TworealRoots);
30+
console.log('1X^2 + 3X + 1')

스크립트/2차/2차.cc

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include <node.h>
2+
#include <nan.h>
3+
4+
// DISCRIMINATOR
5+
void 판별자(const v8::FunctionCallbackInfo<v8::Value> &args)
6+
{
7+
8+
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
9+
10+
// AX2 + BX + C
11+
double A = args[0]->NumberValue(context).FromJust();
12+
double B = args[1]->NumberValue(context).FromJust();
13+
double C = args[2]->NumberValue(context).FromJust();
14+
15+
v8::Local<v8::Number> discriminatorVar = Nan::New((B * B) - (4 * A * C));
16+
17+
args.GetReturnValue().Set(discriminatorVar);
18+
}
19+
20+
// POSITIVE ROOT
21+
void POS판별자(const v8::FunctionCallbackInfo<v8::Value> &args)
22+
{
23+
24+
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
25+
26+
// AX2 + BX + C
27+
double A = args[0]->NumberValue(context).FromJust();
28+
double B = args[1]->NumberValue(context).FromJust();
29+
// double C = args[2]->NumberValue(context).FromJust();
30+
double Discriminator = args[2]->NumberValue(context).FromJust(); // C++에서는 제곱근 함수를 수행할 수 없으므로 Python/javascript 엔진으로 소스를 제공합니다.
31+
32+
// v8::Local<v8::Number> discriminatorVar = Nan::New((B * B) - (4 * A * C));
33+
// v8::Local<v8::Number> negB = Nan::New(B * -1);
34+
// v8::Local<v8::Number> twoA = Nan::New(A * 2);
35+
v8::Local<v8::Number> positiveRoot = Nan::New((((B * -1)) + Discriminator) / (A * 2)); // SHIT
36+
37+
args.GetReturnValue().Set(positiveRoot);
38+
}
39+
40+
void NEG판별자(const v8::FunctionCallbackInfo<v8::Value> &args)
41+
{
42+
43+
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
44+
45+
// AX2 + BX + C
46+
double A = args[0]->NumberValue(context).FromJust();
47+
double B = args[1]->NumberValue(context).FromJust();
48+
// double C = args[2]->NumberValue(context).FromJust();
49+
double Discriminator = args[2]->NumberValue(context).FromJust(); // C++에서는 제곱근 함수를 수행할 수 없으므로 Python/javascript 엔진으로 소스를 제공합니다.
50+
51+
// v8::Local<v8::Number> discriminatorVar = Nan::New((B * B) - (4 * A * C));
52+
// v8::Local<v8::Number> negB = Nan::New(B * -1);
53+
// v8::Local<v8::Number> twoA = Nan::New(A * 2);
54+
v8::Local<v8::Number> positiveRoot = Nan::New((((B * -1)) - Discriminator) / (A * 2)); // SHIT
55+
56+
args.GetReturnValue().Set(positiveRoot);
57+
}
58+
59+
void Initialize(v8::Local<v8::Object> exports)
60+
{
61+
NODE_SET_METHOD(exports, "판별자", 판별자); // Quad Discriminator
62+
NODE_SET_METHOD(exports, "POS판별자", POS판별자); // Quad Discriminator POS판별자
63+
NODE_SET_METHOD(exports, "NEG판별자", NEG판별자); // Quad Discriminator NEG판별자
64+
}
65+
NODE_MODULE(addon, Initialize)

스크립트/2차/2차.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const addon = require('./build/Release/2차');
2+
3+
exports.roots = function Roots(a, b, c) {
4+
let outputarr = [];
5+
let discriminatorRaw = addon.판별자(a, b, c);
6+
let discriminator = Math.sqrt(discriminatorRaw);
7+
let discriminatorIMAGINARY = Math.sqrt(discriminatorRaw * -1);
8+
9+
if (discriminatorRaw > 0)
10+
{
11+
// console.log(addon.POS판별자(1, 2, discriminator))
12+
outputarr.push(2)
13+
outputarr.push(addon.POS판별자(a, b, discriminator))
14+
outputarr.push(addon.NEG판별자(a, b, discriminator))
15+
}
16+
17+
18+
if (discriminatorRaw === 0)
19+
{
20+
// console.log(addon.POS판별자(1, 2, discriminator))
21+
outputarr.push(1)
22+
outputarr.push(addon.POS판별자(a, b, discriminator))
23+
outputarr.push(addon.NEG판별자(a, b, discriminator))
24+
}
25+
26+
27+
if (discriminatorRaw < 0)
28+
{
29+
outputarr.push(0)
30+
outputarr.push(addon.POS판별자(a, b, discriminatorIMAGINARY))
31+
outputarr.push(addon.NEG판별자(a, b, discriminatorIMAGINARY))
32+
33+
// console.log(addon.POS판별자(1, 2, discriminatorIMAGINARY))
34+
35+
}
36+
return outputarr;
37+
}

스크립트/2차/Z-2차.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# npm i -g node-gyp
2+
# npm install --save nan
3+
4+
node-gyp configure build

스크립트/2차/binding.gyp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"targets": [
3+
{
4+
"target_name" : "2차",
5+
"sources":["2차.cc"],
6+
"include_dirs" : [
7+
"<!(node -e \"require('nan')\")"
8+
]
9+
}
10+
]
11+
}
12+
13+
# node-gyp configure build
14+
# const addon = require('./build/Release/addon');

0 commit comments

Comments
 (0)