Skip to content

Commit

Permalink
Merge pull request #9 from ELIFE-ASU/dev
Browse files Browse the repository at this point in the history
Update to version 0.0.3
  • Loading branch information
dglmoore authored Jul 21, 2016
2 parents b5dbd4e + ecdcfdc commit 4e291e0
Show file tree
Hide file tree
Showing 40 changed files with 1,894 additions and 1,378 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
build

# Visual Studio Code
.vscode
.vscode

# temporary directories
tmp
temp

# distribution directories and files
dist/inform-*
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ cmake_minimum_required(VERSION 2.8)
project(inform C)

set(${PROJECT_NAME}_VERSION_MAJOR 0)
set(${PROJECT_NAME}_VERSION_MINOR 0.2)
set(${PROJECT_NAME}_VERSION_MINOR 0.3)
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR})

message(STATUS "inform version: ${${PROJECT_NAME}_VERSION}")

if (UNIX)
add_definitions("-Wall -Wextra -Werror -Wno-unused-parameter -std=gnu1x")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -pg")
elseif(MSVC)
add_definitions("/Wall")
add_definitions("/DLIBRARY_EXPORTS")
endif()

if (APPLE)
Expand All @@ -19,16 +21,20 @@ endif()
include_directories(include)
add_subdirectory(src)
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES})
add_library(${PROJECT_NAME}_STATIC ${${PROJECT_NAME}_SOURCES})
add_library(${PROJECT_NAME}_static ${${PROJECT_NAME}_SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} VERSION ${${PROJECT_NAME}_VERSION})
set_target_properties(${PROJECT_NAME}_STATIC PROPERTIES OUTPUT_NAME ${PROJECT_NAME} VERSION ${${PROJECT_NAME}_VERSION})
if (MSVC)
set_target_properties(${PROJECT_NAME}_static PROPERTIES VERSION ${${PROJECT_NAME}_VERSION})
else()
set_target_properties(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME} VERSION ${${PROJECT_NAME}_VERSION})
endif()

if (UNIX)
target_link_libraries(${PROJECT_NAME} m)
endif()

install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} DESTINATION lib)
install(TARGETS ${PROJECT_NAME}_STATIC EXPORT ${PROJECT_NAME} DESTINATION lib)
install(TARGETS ${PROJECT_NAME}_static EXPORT ${PROJECT_NAME} DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ Inform is still under heavy development. As such, the API and the feature set ar

## Build Status
- Linux/OSX: [![Build Status](https://travis-ci.org/ELIFE-ASU/Inform.svg?branch=master)](https://travis-ci.org/ELIFE-ASU/Inform)
- Windows: **Appveyor Support Pending**
- Windows: [![Build Status](https://ci.appveyor.com/api/projects/status/7y015h6p7n0q7097/branch/master?svg=true)](https://ci.appveyor.com/project/dglmoore/inform-vx977)
- Code Coverage: **Coming Soon**
15 changes: 15 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 0.0.3.{build}
configuration:
- Debug
- Release
platform:
- x64
- x86
- Any CPU
before_build:
- ps: cmake .
build:
project: ALL_BUILD.vcxproj
verbosity: normal
test_script:
- cmd: test\%CONFIGURATION%\inform_unittest.exe
24 changes: 24 additions & 0 deletions dist/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

function usage {
echo "Usage: ${0##*/} [--prefix=<prefix>]"
exit 1
}

if [[ $# -eq 0 ]]; then
prefix=/usr/local
elif [[ $# -eq 1 ]]; then
prefix=${1#"--prefix="}
if [[ $prefix == $1 ]]; then
prefix=${1#"--PREFIX="}
if [[ $prefix == $1 ]]; then
usage
fi
fi
else
usage
fi

mkdir -p $prefix
cp -R include $prefix
cp -R lib $prefix
20 changes: 20 additions & 0 deletions dist/package.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$version = (cmake . -Bbuild/production -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" | Select-String '-- inform version: ')
$version = $version.ToString().Split(' ')[3]

$prefix = "inform-$version"
$target = "dist/$prefix"
$archive = "$($target)_win-amd64.zip"

cmake . -Bbuild/production -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$target" | Out-Null
cd build/production
nmake
test/inform_unittest.exe
nmake install
cd ../..
Copy-Item LICENSE $target
Copy-Item README.md $target

Remove-Item -force $archive
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
[System.IO.Compression.ZipFile]::CreateFromDirectory($target, $archive, $compressionLevel, $true)
19 changes: 19 additions & 0 deletions dist/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

version=$(cmake -H. -Bbuild/production -DCMAKE_BUILD_TYPE=Release | grep "\-\- inform version:")
version=${version#"-- inform version: "}

target=inform-$version
prefix=dist/$target
tarball=$target"_linux-x86_64.tar.gz"

cmake -H. -Bbuild/production -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$prefix > /dev/null
make -C build/production all test
make -C build/production install > /dev/null
cp dist/install.sh $prefix > /dev/null
cp LICENSE $prefix > /dev/null
cp README.md $prefix > /dev/null

cd dist
echo "Creating tarball: dist/$tarball"
tar czf $tarball $target
13 changes: 8 additions & 5 deletions include/inform/active_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
#pragma once

#include <inform/shannon.h>
#include <inform/error.h>

#ifdef __cplusplus
extern "C"
Expand All @@ -18,9 +18,11 @@ extern "C"
* @param[in] m the number of time steps in each time series
* @param[in] b the base or number of distinct states at each time step
* @param[in] k the history length used to calculate the active information
* @param[out] err an error structure
* @return the active information for the ensemble
*/
double inform_active_info(uint64_t const *series, size_t n, size_t m, uint64_t b, uint64_t k);
EXPORT double inform_active_info(int const *series, size_t n, size_t m, int b,
size_t k, inform_error *err);

/**
* Compute the local active information of a ensemble of time series
Expand All @@ -31,10 +33,11 @@ double inform_active_info(uint64_t const *series, size_t n, size_t m, uint64_t b
* @param[in] b the base or number of distinct states at each time step
* @param[in] k the history length used to calculate the active information
* @param[out] ai the local active information
* @return an error code
* @param[out] err an error structure
* @return a pointer to the local active information array
*/
int inform_local_active_info(uint64_t const *series, size_t n, size_t m,
uint64_t b, uint64_t k, double *ai);
EXPORT double *inform_local_active_info(int const *series, size_t n, size_t m, int b,
size_t k, double *ai, inform_error *err);

#ifdef __cplusplus
}
Expand Down
44 changes: 44 additions & 0 deletions include/inform/block_entropy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2016 ELIFE. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
#pragma once

#include <inform/error.h>

#ifdef __cplusplus
extern "C"
{
#endif

/**
* Compute the block entropy of an ensemble of time series
*
* @param[in] series the ensemble of time series
* @param[in] n the number of initial conditions
* @param[in] m the number of time steps in each time series
* @param[in] b the base or number of distinct states at each time step
* @param[in] k the history length used to calculate the active information
* @param[out] err an error structure
* @return the block entropy for the ensemble
*/
EXPORT double inform_block_entropy(int const *series, size_t n, size_t m, int b,
size_t k, inform_error *err);

/**
* Compute the local block entropy of a ensemble of time series
*
* @param[in] series the ensemble of time series
* @param[in] n the number of initial conditions
* @param[in] m the number of time steps in each time series
* @param[in] b the base or number of distinct states at each time step
* @param[in] k the history length used to calculate the active information
* @param[out] ent the local entropy
* @param[out] err an error structure
* @return a pointer to the local block entropy array
*/
EXPORT double *inform_local_block_entropy(int const *series, size_t n, size_t m,
int b, size_t k, double *ent, inform_error *err);

#ifdef __cplusplus
}
#endif
31 changes: 16 additions & 15 deletions include/inform/dist.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
#pragma once

#include <inform/export.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
Expand Down Expand Up @@ -46,7 +47,7 @@ extern "C"
typedef struct inform_distribution
{
/// the histogram or array of observation frequencies
uint64_t *histogram;
uint32_t *histogram;
/// the size of the support
size_t size;
/// the number of observations made so far
Expand All @@ -64,7 +65,7 @@ typedef struct inform_distribution
* @param[in] n the number of distinct events that could be observed
* @return the distribution
*/
inform_dist* inform_dist_alloc(size_t n);
EXPORT inform_dist* inform_dist_alloc(size_t n);
/**
* Resize the distribution to have new support.
*
Expand All @@ -88,7 +89,7 @@ inform_dist* inform_dist_alloc(size_t n);
* @param[in] n the desired support size
* @return the reallocated distribution
*/
inform_dist* inform_dist_realloc(inform_dist *dist, size_t n);
EXPORT inform_dist* inform_dist_realloc(inform_dist *dist, size_t n);
/**
* Copy a distribution to a destination.
*
Expand All @@ -103,7 +104,7 @@ inform_dist* inform_dist_realloc(inform_dist *dist, size_t n);
* @param[in,out] the destination distribution
* @return a pointer to the copied distribution
*/
inform_dist* inform_dist_copy(inform_dist const *src, inform_dist *dest);
EXPORT inform_dist* inform_dist_copy(inform_dist const *src, inform_dist *dest);
/**
* Duplicate a distribution.
*
Expand All @@ -117,21 +118,21 @@ inform_dist* inform_dist_copy(inform_dist const *src, inform_dist *dest);
* @param[in] dist the source distribution
* @return the new distribution
*/
inform_dist* inform_dist_dup(inform_dist const *dist);
EXPORT inform_dist* inform_dist_dup(inform_dist const *dist);
/**
* Create a distribution from an underlying histogram.
*
* @param[in] data the underlying histogram data
* @param[in] n the number of events in the histogram
* @return the new distribution
*/
inform_dist* inform_dist_create(uint64_t const *data, size_t n);
EXPORT inform_dist* inform_dist_create(uint32_t const *data, size_t n);
/**
* Free all dynamically allocated memory associated with a distribution.
*
* @param[in] dist the distribution to free
*/
void inform_dist_free(inform_dist *dist);
EXPORT void inform_dist_free(inform_dist *dist);

/**
* Get the size of the distribution's support.
Expand All @@ -141,7 +142,7 @@ void inform_dist_free(inform_dist *dist);
* @param[in] dist the distribution
* @return the size of the distribution's support
*/
size_t inform_dist_size(inform_dist const *dist);
EXPORT size_t inform_dist_size(inform_dist const *dist);
/**
* Get the total number of observations so far made.
*
Expand All @@ -150,7 +151,7 @@ size_t inform_dist_size(inform_dist const *dist);
* @param[in] dist the distribution
* @return the number of observations thus far made
*/
uint64_t inform_dist_counts(inform_dist const *dist);
EXPORT uint64_t inform_dist_counts(inform_dist const *dist);
/**
* Determine whether or not the distribution is valid.
*
Expand All @@ -162,7 +163,7 @@ uint64_t inform_dist_counts(inform_dist const *dist);
* @param[in] dist the distribution
* @return the validity of the distribution
*/
bool inform_dist_is_valid(inform_dist const *dist);
EXPORT bool inform_dist_is_valid(inform_dist const *dist);

/**
* Get the number of occurances of a given event.
Expand All @@ -176,7 +177,7 @@ bool inform_dist_is_valid(inform_dist const *dist);
*
* @see inform_dist_set
*/
uint64_t inform_dist_get(inform_dist const *dist, uint64_t event);
EXPORT uint32_t inform_dist_get(inform_dist const *dist, size_t event);
/**
* Set the number of occurances of a given event.
*
Expand All @@ -195,7 +196,7 @@ uint64_t inform_dist_get(inform_dist const *dist, uint64_t event);
* @see inform_dist_get
* @see inform_dist_tick
*/
uint64_t inform_dist_set(inform_dist *dist, uint64_t event, uint64_t x);
EXPORT uint32_t inform_dist_set(inform_dist *dist, size_t event, uint32_t x);

/**
* Increment the number of observations of a given event.
Expand All @@ -213,7 +214,7 @@ uint64_t inform_dist_set(inform_dist *dist, uint64_t event, uint64_t x);
*
* @see inform_dist_set
*/
uint64_t inform_dist_tick(inform_dist *dist, uint64_t event);
EXPORT uint32_t inform_dist_tick(inform_dist *dist, size_t event);

/**
* Extact the probability of an event.
Expand All @@ -231,7 +232,7 @@ uint64_t inform_dist_tick(inform_dist *dist, uint64_t event);
* @see inform_dist_get
* @see inform_dist_dump
*/
double inform_dist_prob(inform_dist const *dist, uint64_t event);
EXPORT double inform_dist_prob(inform_dist const *dist, size_t event);
/**
* Dump the probabilities of all events to an array.
*
Expand All @@ -248,7 +249,7 @@ double inform_dist_prob(inform_dist const *dist, uint64_t event);
* @param[in] probs the size of the preallocated array
* @return the number of probabilities written to the array
*/
size_t inform_dist_dump(inform_dist const *dist, double *probs, size_t n);
EXPORT size_t inform_dist_dump(inform_dist const *dist, double *probs, size_t n);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 4e291e0

Please sign in to comment.