Skip to content

Commit 3d09ee0

Browse files
committed
C API corrected, respective makefile and description updated
1 parent 7232dd8 commit 3d09ee0

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ LIB_DEBUG = $(LIB)-lasan
2727
LDFLAGS_DEBUG = $(LDFLAGS)
2828
OBJDIR_DEBUG = obj/Debug
2929
DEP_DEBUG =
30-
OUT_DEBUG = bin/Debug/xmeasures.so
30+
OUT_DEBUG = bin/Debug/libxmeasures.so
3131

3232
INC_RELEASE = $(INC)
3333
CFLAGS_RELEASE = $(CFLAGS) -fomit-frame-pointer -O3 -march=core2 -ftemplate-backtrace-limit=32 -Wno-strict-aliasing -DTRACE=1 -DVALIDATE=1
@@ -38,7 +38,7 @@ LIB_RELEASE = $(LIB)
3838
LDFLAGS_RELEASE = $(LDFLAGS) -s
3939
OBJDIR_RELEASE = obj/Release
4040
DEP_RELEASE =
41-
OUT_RELEASE = bin/Release/xmeasures.so
41+
OUT_RELEASE = bin/Release/libxmeasures.so
4242

4343
OBJ_DEBUG = $(OBJDIR_DEBUG)/src/interface.o $(OBJDIR_DEBUG)/src/interface_c.o
4444

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Some core functionality of xmeasures is available as a library with C API, makin
6767
The interface is defined in `include/interface_c.h`.
6868
To build the library, execute:
6969
```
70-
$ make -f makefile_libxmeasures release
70+
$ make -f Makefile_lib release
7171
```
7272

7373
# Usage

include/interface_c.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,19 @@ typedef float Probability;
7777
//! \param cn1 const ClusterCollection - first collection of clusters (node relations)
7878
//! \param cn2 const ClusterCollection - second collection
7979
//! \param kind F1Kind - kind of F1 to be evaluated
80-
//! \param rec Probability& - recall of cn2 relative to the ground-truth cn1 or
80+
//! \param[out] rec Probability* - recall of cn2 relative to the ground-truth cn1 or
8181
//! 0 if the matching strategy does not have the precision/recall notations
82-
//! \param prc Probability& - precision of cn2 relative to the ground-truth cn1 or
82+
//! \param[out] prc Probability* - precision of cn2 relative to the ground-truth cn1 or
8383
//! 0 if the matching strategy does not have the precision/recall notations
8484
//! \param mkind=MATCH_WEIGHTED MatchKind - matching kind
8585
//! \param verbose=0 uint8_t - print intermediate results to the stdout
8686
//! \return Probability - resulting F1_gm
8787
Probability f1x(const ClusterCollection cn1, const ClusterCollection cn2, F1Kind kind
88-
, Probability& rec, Probability& prc, MatchKind mkind, uint8_t verbose);
88+
, Probability* rec, Probability* prc, MatchKind mkind, uint8_t verbose);
8989
Probability f1(const ClusterCollection cn1, const ClusterCollection cn2, F1Kind kind
90-
, Probability& rec, Probability& prc); // MATCH_WEIGHTED, false
90+
, Probability* rec, Probability* prc); // MATCH_WEIGHTED, false
91+
Probability f1p(const ClusterCollection cn1, const ClusterCollection cn2); // MATCH_WEIGHTED, false
92+
Probability f1h(const ClusterCollection cn1, const ClusterCollection cn2); // MATCH_WEIGHTED, false
9193

9294
//! \brief (Extended) Omega Index evaluation
9395
//!

src/interface_c.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,31 @@ Collection<Id> loadCollection(const ClusterCollection rcn, bool makeunique
158158
}
159159

160160
// Interface implementation ----------------------------------------------------
161+
Probability f1p(const ClusterCollection cn1, const ClusterCollection cn2)
162+
{
163+
return f1(cn1, cn2, F1_PARTPROB, nullptr, nullptr);
164+
}
165+
166+
Probability f1h(const ClusterCollection cn1, const ClusterCollection cn2)
167+
{
168+
return f1(cn1, cn2, F1_HARMONIC, nullptr, nullptr);
169+
}
170+
161171
Probability f1(const ClusterCollection cn1, const ClusterCollection cn2, F1Kind kind
162-
, Probability& rec, Probability& prc)
172+
, Probability* rec, Probability* prc)
163173
{
164-
return f1x(cn1, cn2, kind, rec, prc, MATCH_WEIGHTED, 0);
174+
Probability tmp; // Temporary buffer, a placeholder
175+
return f1x(cn1, cn2, kind, rec ? rec : &tmp, prc ? prc : &tmp, MATCH_WEIGHTED, 0);
165176
}
166177

167178
Probability f1x(const ClusterCollection cn1, const ClusterCollection cn2, F1Kind kind
168-
, Probability& rec, Probability& prc, MatchKind mkind, uint8_t verbose)
179+
, Probability* rec, Probability* prc, MatchKind mkind, uint8_t verbose)
169180
{
170181
// Load nodes
171182
const auto c1 = loadCollection(cn1);
172183
const auto c2 = loadCollection(cn2);
173-
return Collection<Id>::f1(c1, c2, static_cast<F1>(kind), rec, prc, static_cast<Match>(mkind), verbose);
184+
assert(rec && prc && "Invalid output arguments");
185+
return Collection<Id>::f1(c1, c2, static_cast<F1>(kind), *rec, *prc, static_cast<Match>(mkind), verbose);
174186
}
175187

176188
Probability omega(const ClusterCollection cn1, const ClusterCollection cn2)

0 commit comments

Comments
 (0)