def integer_mixed_cells(mixture, points, verbose=True): r""" Given a tuple of lifted support sets in *points*, computes all mixed cells in the regular subdivision defined by the integer lifting values given as the last coordinate of every point in the lifted supports. If *verbose*, then output is written to screen. Returns the mixed volume as the sum of the volumes of the cells. """ from ast import literal_eval from phcpy.phcpy2c3 import py2c_intcelcon_set_type_of_mixture as setmix from phcpy.phcpy2c3 import py2c_intcelcon_type_of_mixture as getmix from phcpy.phcpy2c3 import py2c_intcelcon_initialize_supports as initsup from phcpy.phcpy2c3 import py2c_intcelcon_append_lifted_point as applpt from phcpy.phcpy2c3 import py2c_intcelcon_get_lifted_point as getlpt from phcpy.phcpy2c3 import py2c_intcelcon_length_of_supports as lensup from phcpy.phcpy2c3 import py2c_intcelcon_make_subdivision as makesub from phcpy.phcpy2c3 import py2c_intcelcon_number_of_cells as nbrcells from phcpy.phcpy2c3 import py2c_intcelcon_get_inner_normal as getnormal from phcpy.phcpy2c3 import py2c_intcelcon_mixed_volume as mixvol from phcpy.phcpy2c3 import py2c_intcelcon_write_mixed_cell_configuration setmix(len(mixture), str(mixture)) if verbose: print('the type of mixture stored :', getmix()) initsup(len(mixture)) for k in range(len(points)): if verbose: print('points', k, points[k]) for point in points[k]: if verbose: print('append lifted point :', point) applpt(len(point), k + 1, str(point)) lenpts = literal_eval(lensup()) if verbose: dim = len(points[0][0]) print('lengths of supports :', lenpts) for i in range(len(lenpts)): print('lifted points in support', i, ':') for j in range(lenpts[k]): print(getlpt(dim, i + 1, j + 1)) makesub() if verbose: py2c_intcelcon_write_mixed_cell_configuration() number = nbrcells() totmv = 0 if verbose: dim = len(points[0][0]) print('number of cells :', number) for k in range(number): print('cell', k + 1, 'has normal :', getnormal(dim, k + 1), end='') mv = mixvol(k + 1) print(' mixed volume :', mv) totmv = totmv + mv else: totmv = 0 for k in range(number): totmv = totmv + mixvol(k + 1) return totmv
def integer_mixed_cells(mixture, points, verbose=True): r""" Given a tuple of lifted support sets in *points*, computes all mixed cells in the regular subdivision defined by the integer lifting values given as the last coordinate of every point in the lifted supports. If *verbose*, then output is written to screen. Returns the mixed volume as the sum of the volumes of the cells. """ from ast import literal_eval from phcpy.phcpy2c3 import py2c_intcelcon_set_type_of_mixture as setmix from phcpy.phcpy2c3 import py2c_intcelcon_type_of_mixture as getmix from phcpy.phcpy2c3 import py2c_intcelcon_initialize_supports as initsup from phcpy.phcpy2c3 import py2c_intcelcon_append_lifted_point as applpt from phcpy.phcpy2c3 import py2c_intcelcon_get_lifted_point as getlpt from phcpy.phcpy2c3 import py2c_intcelcon_length_of_supports as lensup from phcpy.phcpy2c3 import py2c_intcelcon_make_subdivision as makesub from phcpy.phcpy2c3 import py2c_intcelcon_number_of_cells as nbrcells from phcpy.phcpy2c3 import py2c_intcelcon_get_inner_normal as getnormal from phcpy.phcpy2c3 import py2c_intcelcon_mixed_volume as mixvol from phcpy.phcpy2c3 import py2c_intcelcon_write_mixed_cell_configuration setmix(len(mixture), str(mixture)) if verbose: print('the type of mixture stored :', getmix()) initsup(len(mixture)) for k in range(len(points)): if verbose: print('points', k, points[k]) for point in points[k]: if verbose: print('append lifted point :', point) applpt(len(point), k+1, str(point)) lenpts = literal_eval(lensup()) if verbose: dim = len(points[0][0]) print('lengths of supports :', lenpts) for i in range(len(lenpts)): print('lifted points in support', i, ':') for j in range(lenpts[k]): print(getlpt(dim,i+1,j+1)) makesub() if verbose: py2c_intcelcon_write_mixed_cell_configuration() number = nbrcells() totmv = 0 if verbose: dim = len(points[0][0]) print('number of cells :', number) for k in range(number): print('cell', k+1, 'has normal :', getnormal(dim, k+1), end='') mv = mixvol(k+1) print(' mixed volume :', mv) totmv = totmv + mv else: totmv = 0 for k in range(number): totmv = totmv + mixvol(k+1) return totmv;
def integer_mixed_cell(dim, nbr, idx, verbose=True): r""" Given are three integers and one boolean, respectively: *dim*: the number of coordinates in the inner normal, *nbr*: the number of distinct supports, *idx*: the index to the cell (starts at one, instead of at zero), and *verbose*: the verbose flag. Returns the extracted data for the mixed cell with index *idx*. If verbose, the data is written to screen. """ from ast import literal_eval from phcpy.phcpy2c3 import py2c_intcelcon_get_inner_normal as getnormal from phcpy.phcpy2c3 import py2c_intcelcon_mixed_volume as mixvol from phcpy.phcpy2c3 import py2c_intcelcon_number_of_points_in_cell as npts from phcpy.phcpy2c3 import py2c_intcelcon_get_point_in_cell as getpoint normal = literal_eval(getnormal(dim, idx)) mv = mixvol(idx) lenpts = literal_eval(npts(idx, nbr)) if verbose: print('inner normal :', normal) print('mixed volume :', mv) print('number of points :', lenpts) supp = [[] for _ in range(nbr)] for i in range(nbr): # scan the i-th support if verbose: print('points in support', i + 1, ':') for j in range(lenpts[i]): # get j-th point in i-th support point = getpoint(dim, idx, i + 1, j + 1) if verbose: print(eval(point)) supp[i].append(eval(point)) return (normal, mv, tuple(supp))
def integer_mixed_cell(dim, nbr, idx, verbose=True): r""" Given are three integers and one boolean, respectively: *dim*: the number of coordinates in the inner normal, *nbr*: the number of distinct supports, *idx*: the index to the cell (starts at one, instead of at zero), and *verbose*: the verbose flag. Returns the extracted data for the mixed cell with index *idx*. If verbose, the data is written to screen. """ from ast import literal_eval from phcpy.phcpy2c3 import py2c_intcelcon_get_inner_normal as getnormal from phcpy.phcpy2c3 import py2c_intcelcon_mixed_volume as mixvol from phcpy.phcpy2c3 import py2c_intcelcon_number_of_points_in_cell as npts from phcpy.phcpy2c3 import py2c_intcelcon_get_point_in_cell as getpoint normal = literal_eval(getnormal(dim, idx)) mv = mixvol(idx) lenpts = literal_eval(npts(idx, nbr)) if verbose: print('inner normal :', normal) print('mixed volume :', mv) print('number of points :', lenpts) supp = [ [] for _ in range(nbr)] for i in range(nbr): # scan the i-th support if verbose: print('points in support', i+1, ':') for j in range(lenpts[i]): # get j-th point in i-th support point = getpoint(dim, idx, i+1, j+1) if verbose: print(eval(point)) supp[i].append(eval(point)) return (normal, mv, tuple(supp))