gibbs
Differences
This shows you the differences between two versions of the page.
Last revisionBoth sides next revision | |||
gibbs [2012/11/15 14:45] – created ignacy | gibbs [2012/11/15 14:46] – ignacy | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Module | + | Module |
+ | |||
+ | Ignacy Misztal, University of Georgia | ||
+ | 04/ | ||
- | Written by Ignacy Misztal, University of Georgia | + | Introduction |
- | June 6, 2001 - July 16, 2001 | + | ============ |
- | Module | + | Module |
- | Fortran 90. Operations include: | + | implementing the Gibbs sampler predominantly |
+ | To understand the module fully, please read the documentation on modules | ||
+ | SPARSEM and PROB, and on BLUPF90. | ||
- | 1. declare a table | + | Subroutine link_hash was inspired by Urs Schnyder, ETH, Switzerland. |
- | type (db_hash):: | ||
- | |||
- | where x is a database | ||
- | |||
- | 2, Initialize | ||
- | call init(x) | + | Module Gibbs |
- | + | ============ | |
- | 3. Declare fields | + | |
- | call add_field(x, | ||
- | |||
- | where alphanumeric variable name contains name of field, type is | ||
- | | ||
- | or " | ||
- | " | ||
- | |||
- | 4. Indicate which field is an index | ||
- | call set_index(x, | + | LINK_HASH |
- | + | ---------- | |
- | where name is an alphanumeric variable containing the name of field that | + | |
- | will serve as index. All searches are by the index. | + | |
- | 5. Indicate that all field definitions are provided | + | call link_hash_ija(xx, |
- | call align_db(x) | + | xx - matrix in sparse_hashm format |
- | + | xx_ija - matrix | |
- | 6. Specify the initial number of elements | + | |
- | call zero(x,n) | + | Matrix in sparse_hashm form can be rapidly constructed but cannot |
- | + | easily be used. Matrix in sparse_ija form can easily be used but | |
- | where n contains | + | cannot be set up directly. Conversion from sparse_hashm to sparse_ija |
- | warning: | + | as provided in module SPARSEM is relatively slow. Subroutine link_hash |
- | + | provides a fast conversion from sparse_hashm to sparse_ija format when xx | |
- | | + | with the same nonzero structure needs to be converted repeatedly. When |
- | 7. Insert elements | + | this routine is called the first time, a link is created that |
+ | points to equivalent locations in xx and xx_ija. During subsequent | ||
+ | calls, it is assumed that the nonzero structure of xx and xx_ija | ||
+ | remains the same, and the conversion is done rapidly by using the link | ||
+ | to update the numerical values only. | ||
- | call insert_el(x, | ||
- | |||
- | where name is name of field and val its value; the type of val corresponds | ||
- | to the type of field. Insertion is into the current record. However, if | ||
- | the field is an index, the action depends on whether a record with | ||
- | val as an index exists. If it does, that record will become the current | ||
- | | ||
- | | ||
- | 8. Reposition pointer to a current record | + | Solve_iterm_block |
+ | ----------------- | ||
- | stat=move_rec(x,direction) | + | call solve_iterm_block(xx_ija,xy,sol,i,j, |
- | + | ||
- | | + | |
- | " | + | |
- | | + | |
- | + | ||
- | 9. Retrieve elements | + | |
- | stat=find_index(x,val) | + | xx_ija - Matrix in sparse_ija format |
- | | + | xy |
- | tries to locate an entry with index value val; if successful, stat is | + | sol - (r8) vector of solutions |
- | | + | i - integer |
- | stat is set to .false. | + | j - integer value of last equation |
- | + | diag - (r8) matrix of dimension j-i+1 x j-i+1 | |
+ | op - a character variable containing either ' | ||
+ | When op=' | ||
+ | equations from i to j, and puts the diagonal part of the matrix xx_ija | ||
+ | into a dense matrix diag. When op=' | ||
+ | updated for the current block of solutions. The " | ||
+ | always follow the " | ||
+ | The need for the ' | ||
- | call get_el(x, | ||
- | |||
- | | ||
+ | Other subroutines | ||
+ | ------------------ | ||
- | + | Extra subroutines (undocumented) have been added to enable multiple-trait | |
- | Additional | + | Gibbs-sampling with single-trait |
- | + | gibbs1f90.f90 for details. | |
- | A. Printing | + | |
- | + | ||
- | call print_entry(x,form,un) | + | |
- | + | ||
- | prints the current entry; | + | |
- | optional form specifies format | + | |
- | optional un specifies unit; by default the output goes to the terminal | + | |
- | + | ||
- | + | ||
- | call print_table(x, | + | |
- | + | ||
- | prints all entries | + | |
- | optional form specifies format | + | |
- | optional un specifies unit; by default the output goes to the | + | |
- | terminal | + | |
- | + | ||
- | + | ||
- | B. Printing database information | + | |
- | + | ||
- | call print_setup(x) | + | |
- | + | ||
- | shows order of fields and their physical location in table x | + | |
- | + | ||
- | + | ||
- | C. Reading and writing | + | |
- | + | ||
- | call write(setup(x, | + | |
- | + | ||
- | | + | |
- | + | ||
- | call write_data(x, | + | |
- | + | ||
- | | + | |
- | " | + | |
- | + | ||
- | call read_setup(x, | + | |
- | + | ||
- | reads setup into an existing or empty database from file name. | + | |
- | + | ||
- | call read_data(x, | + | |
- | + | ||
- | reads contents of database from file name into x; optional form is | + | |
- | " | + | |
- | | + | |
- | of entries. | + | |
- | + | ||
- | call expand(x, | + | |
- | + | ||
- | | + | |
- | n is present. | + | |
- | + | ||
- | + | ||
- | D. Sorting, clustring, numbering, etc. | + | |
- | + | ||
- | call add_count(x, | + | |
- | + | ||
- | adds consecutive numbering from 1 to given field; | + | |
- | if optional type=' | + | |
- | indixes; otherwise, numbering is by random order. | + | |
- | + | ||
- | subroutine sort_db(x, | + | |
- | + | ||
- | sorts x specified by optional field and order | + | |
- | if optional fields are missing, sort by index in asecnding order | + | |
- | + | ||
- | fields is a character variable containing fields to be sorted; fields | + | |
- | are separated by spaces | + | |
- | optional order is ' | + | |
- | + | ||
- | + | ||
- | + | ||
- | ============================= | + | |
- | Selected low-level routines | + | |
- | ============================= | + | |
- | + | ||
- | All routines below operate on 2D integer | + | |
- | columns, i.e., x(:,i) is one entry | + | |
- | + | ||
- | 1. Hash insertion | + | |
- | + | ||
- | | + | |
- | + | ||
- | tries to find such i: x(1: | + | |
- | if unsuccessful, | + | |
- | + | ||
- | if mode=0 (writing): | + | |
- | ind is stored in an empty (all 0) location and i is set to that | + | |
- | location; if there is no space, i is set to -1 | + | |
- | + | ||
- | if mode=1 (retrieval): | + | |
- | i is set to 0 | + | |
- | + | ||
- | + | ||
- | 2. Sorting | + | |
- | + | ||
- | call sort(x, | + | |
- | + | ||
- | sorts columns x by rows in vector x; if optional n is present, only | + | |
- | first n columns are sorted. | + | |
- | + | ||
- | 3. Clustering | + | |
- | + | ||
- | call clustermat(x, | + | |
- | + | ||
- | clusters columns of x with nonxero first-row at the beginning of the matrix; | + | |
- | n is set to the number of nonzero elements | + | |
- | + | ||
- | call | + | |
- | + | ||
- | + |
gibbs.txt · Last modified: 2024/03/25 18:22 by 127.0.0.1