-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adds TypeScript types --------- Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
- Loading branch information
1 parent
8df7373
commit f3e834b
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Accessor function. | ||
* | ||
* @param value - input value | ||
* @returns numerical value | ||
*/ | ||
type AccessorFunction<T> = (value: T) => number; | ||
|
||
/** | ||
* Computes the cosine similarity between two arrays. | ||
* | ||
* @param x - input array | ||
* @param y - input array | ||
* @param accessor - accessor function for accessing array values | ||
* @returns cosine similarity or null | ||
*/ | ||
declare function similarity( | ||
x: number[], | ||
y: number[], | ||
): number | null; | ||
declare function similarity<T>( | ||
x: T[], | ||
y: T[], | ||
accessor: AccessorFunction<T> | ||
): number | null; | ||
|
||
export default similarity |