Skip to content

Commit

Permalink
C API corrected, respective makefile and description updated
Browse files Browse the repository at this point in the history
  • Loading branch information
luav committed Mar 13, 2021
1 parent 7232dd8 commit 3d09ee0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions makefile_libxmeasures → Makefile_lib
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LIB_DEBUG = $(LIB)-lasan
LDFLAGS_DEBUG = $(LDFLAGS)
OBJDIR_DEBUG = obj/Debug
DEP_DEBUG =
OUT_DEBUG = bin/Debug/xmeasures.so
OUT_DEBUG = bin/Debug/libxmeasures.so

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

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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Some core functionality of xmeasures is available as a library with C API, makin
The interface is defined in `include/interface_c.h`.
To build the library, execute:
```
$ make -f makefile_libxmeasures release
$ make -f Makefile_lib release
```

# Usage
Expand Down
10 changes: 6 additions & 4 deletions include/interface_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ typedef float Probability;
//! \param cn1 const ClusterCollection - first collection of clusters (node relations)
//! \param cn2 const ClusterCollection - second collection
//! \param kind F1Kind - kind of F1 to be evaluated
//! \param rec Probability& - recall of cn2 relative to the ground-truth cn1 or
//! \param[out] rec Probability* - recall of cn2 relative to the ground-truth cn1 or
//! 0 if the matching strategy does not have the precision/recall notations
//! \param prc Probability& - precision of cn2 relative to the ground-truth cn1 or
//! \param[out] prc Probability* - precision of cn2 relative to the ground-truth cn1 or
//! 0 if the matching strategy does not have the precision/recall notations
//! \param mkind=MATCH_WEIGHTED MatchKind - matching kind
//! \param verbose=0 uint8_t - print intermediate results to the stdout
//! \return Probability - resulting F1_gm
Probability f1x(const ClusterCollection cn1, const ClusterCollection cn2, F1Kind kind
, Probability& rec, Probability& prc, MatchKind mkind, uint8_t verbose);
, Probability* rec, Probability* prc, MatchKind mkind, uint8_t verbose);
Probability f1(const ClusterCollection cn1, const ClusterCollection cn2, F1Kind kind
, Probability& rec, Probability& prc); // MATCH_WEIGHTED, false
, Probability* rec, Probability* prc); // MATCH_WEIGHTED, false
Probability f1p(const ClusterCollection cn1, const ClusterCollection cn2); // MATCH_WEIGHTED, false
Probability f1h(const ClusterCollection cn1, const ClusterCollection cn2); // MATCH_WEIGHTED, false

//! \brief (Extended) Omega Index evaluation
//!
Expand Down
20 changes: 16 additions & 4 deletions src/interface_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,31 @@ Collection<Id> loadCollection(const ClusterCollection rcn, bool makeunique
}

// Interface implementation ----------------------------------------------------
Probability f1p(const ClusterCollection cn1, const ClusterCollection cn2)
{
return f1(cn1, cn2, F1_PARTPROB, nullptr, nullptr);
}

Probability f1h(const ClusterCollection cn1, const ClusterCollection cn2)
{
return f1(cn1, cn2, F1_HARMONIC, nullptr, nullptr);
}

Probability f1(const ClusterCollection cn1, const ClusterCollection cn2, F1Kind kind
, Probability& rec, Probability& prc)
, Probability* rec, Probability* prc)
{
return f1x(cn1, cn2, kind, rec, prc, MATCH_WEIGHTED, 0);
Probability tmp; // Temporary buffer, a placeholder
return f1x(cn1, cn2, kind, rec ? rec : &tmp, prc ? prc : &tmp, MATCH_WEIGHTED, 0);
}

Probability f1x(const ClusterCollection cn1, const ClusterCollection cn2, F1Kind kind
, Probability& rec, Probability& prc, MatchKind mkind, uint8_t verbose)
, Probability* rec, Probability* prc, MatchKind mkind, uint8_t verbose)
{
// Load nodes
const auto c1 = loadCollection(cn1);
const auto c2 = loadCollection(cn2);
return Collection<Id>::f1(c1, c2, static_cast<F1>(kind), rec, prc, static_cast<Match>(mkind), verbose);
assert(rec && prc && "Invalid output arguments");
return Collection<Id>::f1(c1, c2, static_cast<F1>(kind), *rec, *prc, static_cast<Match>(mkind), verbose);
}

Probability omega(const ClusterCollection cn1, const ClusterCollection cn2)
Expand Down

0 comments on commit 3d09ee0

Please sign in to comment.