Skip to content

Commit

Permalink
qsp-functions file
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed May 30, 2024
1 parent c78c6b7 commit 093803e
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bin/heta-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ prompt(questions)
}
}

// saving qsp-units.heta
// saving qsp-units.heta and qsp-functions.heta
fs.copySync(
path.join(__dirname, './init/qsp-units.heta'),
path.join(targetDir, 'src/qsp-units.heta')
);
fs.copySync(
path.join(__dirname, './init/qsp-functions.heta'),
path.join(targetDir, 'src/qsp-functions.heta')
);
// saving platform file
fs.outputJsonSync(filePath, platform, {spaces: 2});
// saving .gitignore
Expand Down
2 changes: 1 addition & 1 deletion bin/init/index0.heta
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
template file for creating platform
*/
// add qsp units
include ./qsp-units.heta;
//include ./qsp-functions.heta;

// include module.heta type heta;
// include table.xlsx type table with { sheet: 0, omitRows: 3 };
Expand Down
2 changes: 1 addition & 1 deletion bin/init/index1.heta
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
template file for creating platform
*/
// add qsp units
include ./qsp-units.heta;
//include ./qsp-functions.heta;

// @Const
include ./table.xlsx type table with { sheet: 0, omitRows: 3 };
Expand Down
69 changes: 69 additions & 0 deletions bin/init/qsp-functions.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Additional functions which can be used in Heta platforms
can be added to index file by include ./qsp-functions.heta;
*/

// hyperbolic functions

#defineFunction sinh {
arguments: [x],
math: "0.5 * (exp(x) - exp(-x))"
};

#defineFunction cosh {
arguments: [x],
math: "0.5 * (exp(x) + exp(-x))"
};

#defineFunction tanh {
arguments: [x],
math: "(exp(2 * x) - 1) / (exp(2 * x) + 1)"
};

#defineFunction sech {
arguments: [x],
math: "1 / cosh(x)"
};

#defineFunction csch {
arguments: [x],
math: "1 / sinh(x)"
};

#defineFunction coth {
arguments: [x],
math: "1 / tanh(x)"
};


// inverse hyperbolic functions

#defineFunction arcsinh {
arguments: [x],
math: "ln(x + sqrt(x^2 + 1))"
};

#defineFunction arccosh {
arguments: [x],
math: "ln(x + sqrt(x^2 - 1))"
};

#defineFunction arctanh {
arguments: [x],
math: "0.5 * ln((1 + x) / (1 - x))"
};

#defineFunction arcsech {
arguments: [x],
math: "ln((1 + sqrt(1 - x^2)) / x)"
};

#defineFunction arccsch {
arguments: [x],
math: "ln(1 / x + sqrt(1 + 1 / x^2))"
};

#defineFunction arccoth {
arguments: [x],
math: "0.5 * ln((x + 1) / (x - 1))"
};
34 changes: 34 additions & 0 deletions cases/26-additional-functions/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### Basic .gitattributes for a Heta repo.
# Note that binary is a macro for -text -diff.

* text=auto

# main files
# to have heta files in linux style line endings
*.heta text eol=lf
*.xlsx binary

# auxilary files
*.bash text eol=lf
*.sh text eol=lf
*.xlsm binary
*.xls binary
*.pptx binary
*.ppt binary

# code
*.md text
*.m text
# -diff
*.slv text eol=crlf diff=slv
*.dat text eol=crlf diff=dat
*.cpp text
*.svg text diff=xml
*.xml text diff=xml
*.sbml text diff=xml

# LFS (large files)
large/* filter=lfs diff=lfs merge=lfs -text
literature/* filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
11 changes: 11 additions & 0 deletions cases/26-additional-functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Heta specific files and dirs
/dist
/draft
/drafts
/meta

### temporal files
*.tmp
~$*.*
*.log
.Rhistory
12 changes: 12 additions & 0 deletions cases/26-additional-functions/platform.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"builderVersion": "^0.8.2",
"id": "template",
"notes": "platform notes",
"version": "v0.1.0",
"license": "UNLICENSED",
"options": {},
"importModule": {
"type": "heta",
"source": "src/index.heta"
}
}
25 changes: 25 additions & 0 deletions cases/26-additional-functions/src/index.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
template file for creating platform
*/
// add qsp units
include ./qsp-units.heta;
include ./qsp-functions.heta;

// include module.heta type heta;
// include table.xlsx type table with { sheet: 0, omitRows: 3 };
// include addon.json type json;
// include addon.yml type yaml;

p1 @Record .= 1;

// exports
#export { format: JSON, filepath: output };
//#export { format: YAML };
//#export { format: XLSX, omitRows: 3, splitByClass: true };
//#export { format: SBML, version: L2V4 };
//#export { format: SLV, eventsOff: false };
//#export { format: DBSolve };
//#export { format: Simbio };
//#export { format: Mrgsolve };
//#export { format: Matlab };
//#export { format: Julia };
69 changes: 69 additions & 0 deletions cases/26-additional-functions/src/qsp-functions.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Additional functions which can be used in Heta platforms
can be added to index file by include ./qsp-functions.heta;
*/

// hyperbolic functions

#defineFunction sinh {
arguments: [x],
math: "0.5 * (exp(x) - exp(-x))"
};

#defineFunction cosh {
arguments: [x],
math: "0.5 * (exp(x) + exp(-x))"
};

#defineFunction tanh {
arguments: [x],
math: "(exp(2 * x) - 1) / (exp(2 * x) + 1)"
};

#defineFunction sech {
arguments: [x],
math: "1 / cosh(x)"
};

#defineFunction csch {
arguments: [x],
math: "1 / sinh(x)"
};

#defineFunction coth {
arguments: [x],
math: "1 / tanh(x)"
};


// inverse hyperbolic functions

#defineFunction arcsinh {
arguments: [x],
math: "ln(x + sqrt(x^2 + 1))"
};

#defineFunction arccosh {
arguments: [x],
math: "ln(x + sqrt(x^2 - 1))"
};

#defineFunction arctanh {
arguments: [x],
math: "0.5 * ln((1 + x) / (1 - x))"
};

#defineFunction arcsech {
arguments: [x],
math: "ln((1 + sqrt(1 - x^2)) / x)"
};

#defineFunction arccsch {
arguments: [x],
math: "ln(1 / x + sqrt(1 + 1 / x^2))"
};

#defineFunction arccoth {
arguments: [x],
math: "0.5 * ln((x + 1) / (x - 1))"
};
Loading

0 comments on commit 093803e

Please sign in to comment.