Repository navigation
Update Duplicate Detection #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Lightning11wins
wants to merge
430
commits into
master
Choose a base branch
from
dups
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21,422
−5,545
Open
Changes from all commits
Commits
Show all changes
430 commits
Select commit
Hold shift + click to select a range
374465b
Add tests for the xhash module.
Lightning11wins ce94e00
Revert changes to mssError() which are better done elsewhere.
Lightning11wins 89d7080
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 01aa69a
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 3232247
Merge branch 'add-utils' into dups
Lightning11wins 5817820
Add new test util functions.
Lightning11wins fd58f4c
Fix a warning.
Lightning11wins d80339e
Merge branch 'master' into add-lib-tests
Lightning11wins e00bb47
Merge branch 'refs/heads/add-lib-tests' into dups
Lightning11wins 76e5ddd
Add old cluster tests that I haven't finished fixing yet.
Lightning11wins 821e3fa
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 44d9218
Merge branch 'add-lib-tests' into dups
Lightning11wins 07331c4
Fix test op count.
Lightning11wins ee216a8
Reduce number of edits in test_clusters_01.c to a sane number.
Lightning11wins 237ed02
Fix naming conventions and error handling.
Lightning11wins be8a28e
Fix incorrect expected values and memory leaks.
Lightning11wins a75d28e
Fix edge cases in clusters.c.
Lightning11wins 50129f8
Remove bad registrations.
Lightning11wins d686af8
Remove redundant markdown lines about licensing.
Lightning11wins ac02573
Fix outdated info in the docs.
Lightning11wins d1e8458
Fix xaTrim() on size-0 XArrays.
Lightning11wins 95265a8
Add a #define to explicitly denote the magic number null marker.
Lightning11wins e74e856
Update copyright headers.
Lightning11wins bd35642
Fix markdown links.
Lightning11wins d14403d
Remove glyph.h.
Lightning11wins 3b5e620
Improve doc comment clarity.
Lightning11wins b7eb044
Remove unused requirements file.
Lightning11wins 53b726f
Fix typos and mistakes.
Lightning11wins 1a8780a
Fix a ca_most_similar() guard case blocking a correct value.
Lightning11wins 66bed29
Improve error handling in exp_fn_trim().
Lightning11wins 3814676
Add detail to mlxStringVal() comment.
Lightning11wins ec7bb6d
Add explicit void marker to functions that don't take parameters.
Lightning11wins de53acb
Merge branch 'add-utils' into add-lib-tests
Lightning11wins d950f3c
Merge branch 'add-utils' into dups
Lightning11wins beec7f3
Rename checkNeg() to checkPos().
Lightning11wins 212ed3f
Fix EXPECT_STR_EQL_N() improperly logging null values.
Lightning11wins 3bd80bd
Merge branch 'add-lib-tests' into dups
Lightning11wins 3afbd2a
Merge branch 'add-utils' into add-lib-tests
Lightning11wins c75c69f
Fix a test that used the wrong macro name.
Lightning11wins cbcefd2
Merge branch 'add-utils' into dups
Lightning11wins d30a2f7
Merge branch 'add-lib-tests' into dups
Lightning11wins df9b864
Fix exp_fn_metaphone() clobbering it's return value variable.
Lightning11wins c39de70
Fix typos in xarray.md.
Lightning11wins 7896a30
Fix typos and outdated info in mtsession.md.
Lightning11wins 437b511
Add docs for xaAddItemSortedInt32().
Lightning11wins e595d6f
Fix more typos.
Lightning11wins 2f3ef2e
Rename internal functions.
Lightning11wins 05d3fa1
Merge branch 'add-utils' into dups
Lightning11wins b5f329f
Rename incorrectly named functions to follow the style.
Lightning11wins cea1cfc
Drop a bad test case.
Lightning11wins 46686ab
Fix memory leak in tests.
Lightning11wins 276252d
Add tests for null-terminated list detection in caMostSimilar().
Lightning11wins aa2fc76
Improve the clarity of a warning.
Lightning11wins 2860ff8
Trim comment.
Lightning11wins b6bbdd0
Simplify xhash.c code that was confusing to read.
Lightning11wins 991a581
Remove confusing unused functionality from the cacheFree functions in…
Lightning11wins 96b69ff
Refactor xhForEach() using variable arguments.
Lightning11wins dcb605b
Fix tests requiring an old, buggy behavior.
Lightning11wins f65b919
Fix mistakes in xstring.md.
Lightning11wins c171287
Added a description for %X and %llX.
Lightning11wins 3079d00
Trim example.
Lightning11wins d38f436
Add detail to docs.
Lightning11wins 55c0c32
Merge branch 'add-utils' into add-lib-tests
Lightning11wins b98a4a2
Update the test driver to handle the new snprintBytes() and snprintC…
Lightning11wins c40b5a8
Update the tests to handle and test the new snprintBytes() and snprin…
Lightning11wins 71e19db
Fix mistakes from my attempt to handle an earlier merge conflict.
Lightning11wins d8804a2
Improve test readability.
Lightning11wins 5d18d7a
Fix EXPECT_STR_EQL_N() writing "(null)" into a buffer that might be t…
Lightning11wins 0d5aa2a
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 8d370c3
Fix mistakes and make improvements in objdrv_cluster.c.
Lightning11wins f17c311
Improve code quality in the "Unknown provided parameter" code.
Lightning11wins 6c9942c
Remove redundant expect.h calls on check.h macros.
Lightning11wins 5e6460b
Remove an inaccurate expect.h call.
Lightning11wins 1ad7686
Improve cluster_i_printEntry() value passing.
Lightning11wins c5c2dae
Add a new enum to handle when an unknown data struct is passed.
Lightning11wins e6ede1e
Merge branch 'add-utils' into add-lib-tests
Lightning11wins d431de5
Merge branch 'add-lib-tests' into dups
Lightning11wins 0511a3a
Replace magic values in objdrv_cluster.c with constants.
Lightning11wins de2d402
Improve code readability.
Lightning11wins 2a35dcf
Fix mistakes and stale info.
Lightning11wins 0690dfb
Fix printing formats.
Lightning11wins 5a19737
Fix memory clean up when kmeans clustering fails.
Lightning11wins f26a9bb
Fix memory clean up during source data fetching.
Lightning11wins 6477d93
Fix a possible failure caused by using nmSysMalloc(0).
Lightning11wins d54c5f5
Fix missing deallocation.
Lightning11wins ef42916
Fix comments claiming to know that the provided data source was a dat…
Lightning11wins 3453f0d
Add null checks for data from objGetAttrValue().
Lightning11wins 33c4786
Fix misleading wording in driver authoring docs.
Lightning11wins dde2afd
Improve styling and readability.
Lightning11wins d5ce6a8
Improve the error message when kmeans() fails.
Lightning11wins 16031f2
Hoist logic to simplify code.
Lightning11wins a36e503
Add info for the sys_type parameter of clusterOpen().
Lightning11wins ea82a10
Reduce code complexity caused by gotos in clusterGetAttrValue().
Lightning11wins eeaa3f1
Reduce goto complexity in clusterGetAttrValue().
Lightning11wins 6cfbffa
Modify cluster_i_getParamType() to return -1 if the parameter doesn't…
Lightning11wins 63a66f8
Fix ignored failures that would cause immediate faults.
Lightning11wins 7562d86
Add checkPtr() warnings expCompileExpression() fails when calculating…
Lightning11wins 5a797bc
Fix incorrect presentation hint.
Lightning11wins 0c8db7f
Reduce code complexity caused by gotos.
Lightning11wins 8628a96
Trim unused code.
Lightning11wins 6b901d4
Fix typo.
Lightning11wins cb21976
Improve style of to string functions.
Lightning11wins ede3d9c
Add cluster_i_targetTypeToString().
Lightning11wins 35ff5b0
Add an error message.
Lightning11wins 270eccc
Add a comment to explain why the "unnecessary scope block" is necessary.
Lightning11wins c2bfde2
Fix crash on clusterOpen(NULL, ...).
Lightning11wins 1ce204a
Reduce code complexity caused by gotos.
Lightning11wins b19fa4f
Improve spacing.
Lightning11wins 683ffe0
Clean up.
Lightning11wins baa0131
Add binding support to stGetAttrValueOSML().
Lightning11wins adbdeb2
Update the cluster driver to call stGetAttrValueOSML() with a domain …
Lightning11wins 71e2b44
Fix a type in a function signature.
Lightning11wins 64eab12
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 4e7f324
Replace check.h uses in tests with EXPECT() calls.
Lightning11wins 7d13072
Modify tests to fail immediately when they are about to crash.
Lightning11wins 47b16f9
Rename EXPECT macros to ASSERT.
Lightning11wins 5695672
Increase min test time because some tests blocked enough to not meet …
Lightning11wins 31a477f
Update error handling in stparse.c.
Lightning11wins 56af74a
Fix stGetAttrValueOSML() domain and coverage mask handling.
Lightning11wins 3169947
Implement stGetObjAttrValueOSML().
Lightning11wins 2df11c6
Update the cluster driver to use stGetObjAttrValueOSML().
Lightning11wins 433f992
Use consistent default attribute handling style.
Lightning11wins 5879266
Drop noisy error message.
Lightning11wins ce9c3a4
Merge branch 'add-lib-tests' into dups
Lightning11wins 6309582
Rename EXPECT macros to ASSERT.
Lightning11wins f791c31
Improve spacing in test_clusters_04.c.
Lightning11wins 7551021
Remove check.h usage in tests.
Lightning11wins 28e2f1e
Remove check.h usage in xarray.c.
Lightning11wins 9770c54
Update error handling in clusters.c.
Lightning11wins 144217e
Add xsCharAt() to xstring.
Lightning11wins 032a05e
Add xsConcatenateLiteral() to xstring.
Lightning11wins f4b2c2b
Replace meta strings with XStrings in double_metaphone.c.
Lightning11wins 79f0e66
Update my explanation comment.
Lightning11wins 0927f75
Improve metaphone code style.
Lightning11wins 08730a8
Improve metaphone comments.
Lightning11wins 75526a2
Remove pointer address printing from errors.
Lightning11wins 3947616
Update error handling in stparse.c.
Lightning11wins fbeac7f
Update error handling in exp_functions.c.
Lightning11wins 77e564d
Merge branch 'add-utils' into add-lib-tests
Lightning11wins fab5b19
Merge branch 'add-utils' into dups
Lightning11wins 4968989
Merge branch 'add-utils' into add-lib-tests
Lightning11wins eed6117
Merge branch 'add-utils' into dups
Lightning11wins a1ae63b
Merge branch 'add-lib-tests' into dups
Lightning11wins 074f6be
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 9730ef4
Merge branch 'add-lib-tests' into dups
Lightning11wins 508a408
Disable warnings in cluster tests that spam them.
Lightning11wins 3e8244d
Overhaul error handling in objdrv_cluster.c.
Lightning11wins 5f272f0
Remove code that frees clusters owned by the cluster cache.
Lightning11wins 6010f51
Merge branch 'add-utils' into dups
Lightning11wins ec9454f
Improve comments.
Lightning11wins 1a29da8
Add error checking for strtcpy().
Lightning11wins ad15ebf
Update to use unsigned long instead of unsigned long long for cluster…
Lightning11wins 1eb0532
Add the pSimilarityFn type.
Lightning11wins 6d0cc6e
Fix queries from node targets incrementing the index even if no entry…
Lightning11wins de22409
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 3836241
Merge branch 'add-lib-tests' into dups
Lightning11wins bdef7f9
Merge branch 'master' into dups
Lightning11wins 6cb4b8d
Merge branch 'add-utils' into dups
Lightning11wins 05ac6ef
Modify date_computed to be null on the target node instead of undefined.
Lightning11wins ee3086c
Restructure confusing last_modification code.
Lightning11wins d411e84
Fix an off-by-one when fetching objects from the cluster driver root …
Lightning11wins a69e620
Improve confusing logic for skipping uncomputed caches.
Lightning11wins 5a00454
Fix typos and mistakes (thanks Opus 5.5).
Lightning11wins f582bbf
Fix cmp_Pairs() comparing pointers instead of the pointed data in tes…
Lightning11wins a1b1057
Update a comment about how caCosCompare()'s function signature needs …
Lightning11wins bd76d70
Improve money format printing in 2 errors.
Lightning11wins d1e5325
Remove an extra -lm that was being added to the makefile.
Lightning11wins f6b28de
Update test performance multiplier.
Lightning11wins bb40fa6
Fix all remaining stale mentions of ca_search().
Lightning11wins 5d22dcc
Reorder caEql() to a more intuitive location in the clusters module.
Lightning11wins 8163bab
Replace _PC_PATH_MAX with OBJSYS_MAX_PATH, the actual max path length…
Lightning11wins 0f650fc
Fix a memory leak when xaAddItem() fails.
Lightning11wins cf43c1b
Fix clusterCommit() returning a successful error code despite calling…
Lightning11wins 00c214f
Remove mentions of cluster entry similarities, which were scrapped an…
Lightning11wins 48bbede
Add a memset() for ClusterQuery even though each field is initialized…
Lightning11wins ff9b869
Fix a confusing error message.
Lightning11wins a9942a0
Improve some wording in string_similarity.md.
Lightning11wins 69c0c73
Improve spacing in test_expfn_log_00.to.
Lightning11wins 53d75d4
Fix more typos and mistakes.
Lightning11wins 2503820
Merge branch 'add-utils' into add-lib-tests
Lightning11wins e0fa24f
Add tests for the snprintBytes() bug that was recently fixed.
Lightning11wins ecabce3
Fix obvious mistakes and typos.
Lightning11wins c0491db
Merge branch 'add-lib-tests' into dups
Lightning11wins 3930af0
Document the possible memory leak if excessive recursion occurs.
Lightning11wins d303e42
Revert changes that are not in scope for this work.
Lightning11wins ec6b61d
Fix more typos and mistakes.
Lightning11wins dbbcab0
Merge branch 'master' into add-lib-tests
Lightning11wins 8c1b59f
Improve readability.
Lightning11wins be3fae9
Remove an assert function that should have stayed on the dups branch.
Lightning11wins 4833d29
Update test asserts to use bools.
Lightning11wins 51aff7d
Improve performance of testing functions.
Lightning11wins f7f3b48
Fix ASSERT_STR_EQL() and ASSERT_STR_EQL_N() comparing heap and stack …
Lightning11wins 0126ea6
Merge branch 'add-lib-tests' into dups
Lightning11wins 44c5bb8
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 2452ff9
Fix mistakes and typos.
Lightning11wins 40ca017
Merge branch 'add-lib-tests' into dups
Lightning11wins fef1f58
Fix mistakes and typos.
Lightning11wins 670e2af
Fix mistakes and typos.
Lightning11wins 24ca1e0
Fix mistakes and typos.
Lightning11wins 3210288
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 5312047
Merge branch 'master' into dups
Lightning11wins 51df641
Merge branch 'add-lib-tests' into dups
Lightning11wins 8945cbb
Move objTypeFromStr() and objTypeToStr() to the add-driver-functions …
Lightning11wins 5d49f16
Move objFileName(), objFilePath(), and DRIVER_ATTRIBUTE_NAMES to the …
Lightning11wins e9ffe15
Merge branch 'add-driver-functions' into dups
Lightning11wins aedd7c1
Merge branch 'add-driver-functions' into dups
Lightning11wins 40ed5f8
Merge branch 'add-driver-functions' into dups
Lightning11wins 1efe38a
Fix an error that misused obj_internal_PathPart().
Lightning11wins 0907aad
Merge branch 'add-utils' into add-lib-tests
Lightning11wins 944ba53
Fix mistakes in comments and spacing.
Lightning11wins 45d989b
Merge branch 'master' into add-lib-tests
Lightning11wins 5158f3f
Update tests from master that weren't reformatted yet.
Lightning11wins 227cf87
Fix mistakes, typos, and memory leaks.
Lightning11wins 81a9f07
Fix test operation counting.
Lightning11wins 1d4c9bd
Fix a type mistakes.
Lightning11wins 6096a22
Fix memory leaks in failing valgrind tests.
Lightning11wins 63eedfc
Fix the new malloc test's mockErrorFn() function allocating an error …
Lightning11wins 1c459eb
Remove partial sweeping in some tests to increase coverage.
Lightning11wins f096e09
Fix the Makefile not rebuilding when test_utils.h was updated.
Lightning11wins d2486c4
Fix optimization optimizing out the entire baseline pass test.
Lightning11wins ff8eddd
Shorten the names of tests (test_newmalloc_00's name was too long to …
Lightning11wins c0dd2dc
Improve coverage of nmClear() when caching is enabled..
Lightning11wins 395337a
Drop checkChain() in an xhash test because it asserted internals not …
Lightning11wins f35aa5f
Update op counts.
Lightning11wins ff2a6d7
Handle ctrl+c during tests.
Lightning11wins 98976bc
Fix an overflow in test_mtlexer_13.
Lightning11wins 3885ca4
Fix flakiness in xhash_05.
Lightning11wins 33de0fe
Clean up includes.
Lightning11wins 106da3c
Add the ability for tests to skip themselves.
Lightning11wins 07833f0
Modify test_newmalloc_02.c to skip itself when nmStats() is disabled,…
Lightning11wins 749dddf
Add tests for test_utils.h.
Lightning11wins 45db80a
Rename test_utils.h to t_utils.h.
Lightning11wins 0062ae8
Add comments to reduce confusion.
Lightning11wins fb302b0
Improve spacing.
Lightning11wins ff98431
Refactor t_utils.h macros into functions with t_utils.c for readability.
Lightning11wins 5d36a42
Reorder ASSERT_NOT_NULL() higher up in the file.
Lightning11wins c704341
Fix typos in comments and docs.
Lightning11wins e719764
Fix issues caused by merging master.
Lightning11wins ee0a791
Fix memory correctness issues.
Lightning11wins 69ad2d0
Fix the log expression function's handling of null parameters.
Lightning11wins 8f11bb2
Fix nan being treated as a valid positive or negative double.
Lightning11wins ae6e684
Fix and improve error messages.
Lightning11wins d53bf73
Fix a type in test_utils.h.
Lightning11wins db0dac3
Merge branch 'master' into dups
Lightning11wins 0267e89
Merge remote-tracking branch 'origin/add-lib-tests' into dups
Lightning11wins 73e7b53
Update lib tests because of changes on add-lib-tests.
Lightning11wins 6cf563f
Merge branch 'master' into dups
Lightning11wins 7b28e30
Join dups and apos_autoscale9-slim5 history at master.
Lightning11wins 09f738e
Merge commit '7b28e30d0c3abf4ff908c5f545d3bc9fae17ece8' into dups
Lightning11wins ef0eecb
Clarify a detail about Upserts that caused bugs in my code.
Lightning11wins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,166 @@ | ||
| #ifndef CLUSTERS_H | ||
| #define CLUSTERS_H | ||
|
|
||
| /************************************************************************/ | ||
| /* Centrallix Application Server System */ | ||
| /* Centrallix Core */ | ||
| /* */ | ||
| /* Copyright (C) 1998-2026 LightSys Technology Services, Inc. */ | ||
| /* */ | ||
| /* This program is free software; you can redistribute it and/or modify */ | ||
| /* it under the terms of the GNU General Public License as published by */ | ||
| /* the Free Software Foundation; either version 2 of the License, or */ | ||
| /* (at your option) any later version. */ | ||
| /* */ | ||
| /* This program is distributed in the hope that it will be useful, */ | ||
| /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
| /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | ||
| /* GNU General Public License for more details. */ | ||
| /* */ | ||
| /* You should have received a copy of the GNU General Public License */ | ||
| /* along with this program; if not, write to the Free Software */ | ||
| /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA */ | ||
| /* 02111-1307 USA */ | ||
| /* */ | ||
| /* A copy of the GNU General Public License has been included in this */ | ||
| /* distribution in the file "COPYING". */ | ||
| /* */ | ||
| /* Module: clusters.c, clusters.h */ | ||
| /* Author: Israel Fuller */ | ||
| /* Creation: September 29, 2025 */ | ||
| /* Description: Clustering library used to cluster and search data with */ | ||
| /* cosine or Levenshtein (aka. edit distance) similarity */ | ||
| /* measures. Used by the "clustering driver". */ | ||
| /* For more information on how to use this library, see */ | ||
| /* string_similarity.md in the centrallix-sysdoc folder. */ | ||
| /************************************************************************/ | ||
|
|
||
| #include <stdlib.h> | ||
| #include <stdbool.h> | ||
|
|
||
| #ifdef CXLIB_INTERNAL | ||
| #include "xarray.h" | ||
| #else | ||
| #include "cxlib/xarray.h" | ||
| #endif | ||
|
|
||
| /** This file has additional documentation in string_similarity.md. **/ | ||
|
|
||
|
|
||
| /*** This value defines the number of dimensions used for a sparse | ||
| *** vector. The higher the number, the fewer collisions will be | ||
| *** encountered when using these vectors for cosine comparisons. | ||
| *** This is also called the vector table size, if viewing the | ||
| *** vector as a hash table of character pairs. | ||
| *** | ||
| *** 2147483647 is the signed int max, and is also a prime number. | ||
| *** Using this value ensures that the longest run of 0s will not | ||
| *** cause an int underflow with the current encoding scheme. | ||
| *** | ||
| *** Unfortunately, we can't use a number this large yet because | ||
| *** the kmeans algorithm creates densely allocated centroids with | ||
| *** `CA_NUM_DIMS` dimensions, so a large number causes it to fail. | ||
| *** Thus, we use 251 as the largest prime number less than 256, | ||
| *** giving us a decent balance between collision reduction and | ||
| *** kmeans centroid performance/memory overhead. | ||
| ***/ | ||
| #define CA_NUM_DIMS 251 | ||
|
|
||
| /*** The character used to create a pair with the first and last characters | ||
| *** of a string. Currently set to 96, the character just before 'a' (97) | ||
| *** in the ASCII table. | ||
| ***/ | ||
| #define CA_BOUNDARY_CHAR ((unsigned char)('a' - 1)) | ||
|
|
||
| /** Types. **/ | ||
| typedef int* pVector; /* Sparse vector. */ | ||
| typedef double* pCentroid; /* Dense centroid. */ | ||
| #define CENTROID_SIZE (CA_NUM_DIMS * sizeof(double)) | ||
|
|
||
| /*** Information about detected matching pairs. | ||
| *** | ||
| *** @param i The index into the provided data for the first element of the pair. | ||
| *** @param j The index into the provided data for the second element of the pair. | ||
| *** @param similarity A number from 0 to 1, from a similarity function, showing | ||
| *** how similar the pair is. | ||
| ***/ | ||
| typedef struct | ||
| { | ||
| unsigned int i, j; | ||
| double similarity; | ||
| } | ||
| Pair, *pPair; | ||
|
|
||
|
|
||
| /** Edit distance function. **/ | ||
| int caEditDist(const char* str1, const char* str2, const size_t str1_length, const size_t str2_length); | ||
|
|
||
| /** Vector functions. **/ | ||
| pVector caBuildVector(const char* str); | ||
| bool caEql(pVector v1, pVector v2); | ||
| unsigned int caSparseLen(const pVector vector); | ||
| void caPrintVector(const pVector vector); | ||
| void caFreeVector(pVector sparse_vector); | ||
|
|
||
| /** k-means function. **/ | ||
| int caKmeans( | ||
| pVector* vectors, | ||
| const unsigned int num_vectors, | ||
| const unsigned int num_clusters, | ||
| const unsigned int max_iter, | ||
| const double min_improvement, | ||
| unsigned int* labels, | ||
| double* vector_sims, | ||
| bool auto_seed); | ||
|
|
||
| /** Vector helper macros. **/ | ||
| #define caIsEmpty(vector) (vector[0] == -CA_NUM_DIMS) | ||
| /*** Note: Given that CA_NUM_DIMS == 251, caBuildVector("") will give the | ||
| *** vector we check for in the caHasNoPairs() macro, [-172, 11, -78], | ||
| *** which has a single pair of boundary characters. | ||
| *** If CA_NUM_DIMS is modified, this macro will need to be updated, hence the | ||
| *** compiler directive causing it to be undefined in this case, likely leading | ||
| *** to a lot of compiler or linker issues to remind the developer about this. | ||
| ***/ | ||
| #if CA_NUM_DIMS == 251 | ||
| #define caHasNoPairs(vector) \ | ||
| ({ \ | ||
| __typeof__ (vector) _v = (vector); \ | ||
| _v[0] == -172 && _v[1] == 11 && _v[2] == -78; \ | ||
| }) | ||
| #endif | ||
|
|
||
| /*** A function which takes two data items and returns their similarity, a | ||
| *** value between `0.0` (completely different) and `1.0` (identical). | ||
| ***/ | ||
| typedef double (*pSimilarityFn)(void*, void*); | ||
|
|
||
| /** Comparison functions (matching the pSimilarityFn signature). **/ | ||
| double caCosCompare(void* v1, void* v2); | ||
| double caLevCompare(void* str1, void* str2); | ||
|
|
||
| /** Similarity search functions. **/ | ||
| void* caMostSimilar( | ||
| void* target, | ||
| void** data, | ||
| const unsigned int num_data, | ||
| pSimilarityFn similarity, | ||
| const double threshold); | ||
| pXArray caSlidingSearch( | ||
| void** data, | ||
| const unsigned int num_data, | ||
| const unsigned int window_size, | ||
| pSimilarityFn similarity, | ||
| const double threshold, | ||
| pXArray maybe_pairs); | ||
| pXArray caCompleteSearch( | ||
| void** data, | ||
| const unsigned int num_data, | ||
| pSimilarityFn similarity, | ||
| const double threshold, | ||
| pXArray maybe_pairs); | ||
|
|
||
| /** Module management functions. **/ | ||
| void caInit(void); | ||
|
|
||
| #endif /* End of .h file. */ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.