Skip to main content

rewritten python package of ffp_minvar algorithm

Project description

FFP_MINVAR

Table of Contents

Installation

To install ffp_minvar, use this command in terminal:

pip3 install ffp_minvar

We assume you are using python >= 3.6

Documentation

To use the library, import the module like following:

from ffp_minvar import ffp_minvar_lib

Function Description

  • ffp_minvar_lib.ffp(theta, B, V, Delta)
    • theta: A K-1 array of np.zeros(K)
    • B: An N-K numpy.ndarray
    • V: A K-K diagonal matrix as numpy.ndarray. Note that V must be passed in as a diagonal matrix otherwise a ValueError will be raised.
    • Delta: An N-1 numpy.ndarray. Contains the diagonal entries of the actual N-N matrix D.
  • ffp_minvar_lib.lo_minvar(B, V, Delta)
    • B: An N-K numpy.ndarray
    • V: A K-K diagonal matrix as numpy.ndarray. Note that V must be passed in as a diagonal matrix otherwise a ValueError will be raised.
    • Delta: An N-1 numpy.ndarray. Contains the diagonal entries of the actual N-N matrix D.
  • ffp_minvar_lib.psi(B, V, Delta)
    • B: An N-K numpy.ndarray
    • V: A K-K diagonal matrix as numpy.ndarray. Note that V must be passed in as a diagonal matrix otherwise a ValueError will be raised.
    • Delta: An N-1 numpy.ndarray. Contains the diagonal entries of the actual N-N matrix D.

Examples:

#------------ ffp Test --------------#
print("------------ ffp Test ------------")
ffp_res = ffp_minvar_lib.ffp(theta, B, V, D)  
print(ffp_res)

#------------ Psi Test --------------#
print("------------ Psi Test ------------")
psi_res = ffp_minvar_lib.psi(B, V, D)  
print(psi_res)

#---------- lo_minvar Test ----------#
print("------------ lo_minvar Test ------------")
lo_minvar_res = ffp_minvar_lib.lo_minvar(B, V, D)
print(lo_minvar_res)

Github Description

lib folder stores the source python library.

lib/shared folder stores the .so file used by the python library.

include folder contains the header file of the algorithm.

src folder contains the C file of the algorithm, which uses the GSL library from GNU.

obj folder stores the object file of the compiled C file of the algorithm.

test folder contains tests in C of the functions of the algorithm.

ffp_minvar.py is the original version of the algorithm.

test_lib.py is the test file of the python package.

GSL Download

Note that this part is irrelevant to the installation of ffp_minvar package and is only for the download of GSL library.

OSX

Apparently GSL can be installed through Homebrew via

brew install gsl

though installing it manually is just as simple, which we now describe.

  • Download gsl-latest.tar.gz from the GSL ftp site and unzip it anywhere (e.g. /Downloads)
  • Open the unzipped gsl folder in Terminal (e.g. cd ~/Downloads/gsl-2.4
  • Run sudo ./configure && make && make install

If the above gives a "permission denied" error, instead try

sudo make clean
sudo chown -R $USER .
./configure && make
make install

Ubuntu

sudo apt-get install libgsl-dev

You'll now be able to include GSL into your code from anywhere.

Compilation

Shared

To compile the .so file of the algorithm used by the python package, use this command under root folder.

make alg_lomv.so

PythonTest

To run the test of the python package:

  1. Compile the .so file
  2. Make sure that your current python interpreter has installed numpy, ctypes, pdb, and pathlib.
  3. Use this command under root folder:
    python test_lib.py
    

CTest

To compile the test of the algorithm in c, use this command under root folder:

make test_alg
./test_alg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ffp_minvar-0.1.30.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ffp_minvar-0.1.30-cp39-cp39-macosx_10_15_x86_64.whl (38.5 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

File details

Details for the file ffp_minvar-0.1.30.tar.gz.

File metadata

  • Download URL: ffp_minvar-0.1.30.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for ffp_minvar-0.1.30.tar.gz
Algorithm Hash digest
SHA256 002b541bb5b8e33c291c288b46b438127a8318b2b5d86dc27eb7c25189a97910
MD5 5403c8a46c0558c2ef270a37efe58665
BLAKE2b-256 2686aa096de795bb5feaf6d59f03dcc3f242e91c5dc300f87b0967ca4ec62c8e

See more details on using hashes here.

File details

Details for the file ffp_minvar-0.1.30-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ffp_minvar-0.1.30-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for ffp_minvar-0.1.30-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 bb920e80dbbf692cad5981a97cf7f2730aa232b3d8ceb24140c376ec595762ae
MD5 c93f2b9ae5a83b32eedc9b79414ab168
BLAKE2b-256 9665721e0a83c0adfd26611425f3a1527a7089f239e79be99ccbe7c4e5af02ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page