Package hedge :: Module tools
[hide private]
[frames] | no frames]

Module tools

source code

Miscellaneous helper facilities.


Copyright: Copyright (C) 2007 Andreas Kloeckner

License: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see U{http://www.gnu.org/licenses/}.

Classes [hide private]
  Rotation
  Reflection
  SubsettableCrossProduct
A cross product that can operate on an arbitrary subsets of its two operands and return an arbitrary subset of its result.
  EOCRecorder
  Closable
  BlockMatrix
A block matrix is the sum of different smaller matrices positioned within one big matrix.
  IndexListRegistry
  Future
An abstract interface definition for futures.
  ImmediateFuture
A non-future that immediately has a value available.
  NestedFuture
A future that combines two sub-futures into one.
Functions [hide private]
 
cyl_bessel_j(...)
cyl_bessel_j( (object)arg1, (object)arg2, (object)arg3) -> float :
 
cyl_neumann(...)
cyl_neumann( (object)arg1, (object)arg2, (object)arg3) -> float :
 
is_zero(x) source code
 
relative_error(norm_diff, norm_true) source code
 
has_data_in_numpy_arrays(a, allow_objarray_levels) source code
 
numpy_linear_comb(lin_comb) source code
 
mul_add(afac, a, bfac, b, add_timer=None) source code
 
cyl_bessel_j_prime(nu, z) source code
 
_affine_map___getinitargs__(self) source code
 
plot_1d(f, a, b, steps=100, driver=None) source code
 
is_obj_array(val) source code
 
to_obj_array(ary) source code
 
is_field_equal(a, b) source code
 
make_obj_array(res_list) source code
 
setify_field(f) source code
 
hashable_field(f) source code
 
field_equal(a, b) source code
 
join_fields(*args) source code
 
log_shape(array)
Returns the "logical shape" of the array.
source code
 
with_object_array_or_scalar(f, field) source code
 
ptwise_mul(a, b) source code
 
ptwise_dot(logdims1, logdims2, a1, a2) source code
 
levi_civita(tuple)
Compute an entry of the Levi-Civita tensor for the indices tuple.
source code
 
count_subset(subset) source code
 
full_to_subset_indices(subset, base=0)
Takes a sequence of bools and turns it into an array of indices to be used to extract the subset from the full set.
source code
 
full_to_all_subset_indices(subsets, base=0)
Takes a sequence of bools and generates it into an array of indices to be used to extract the subset from the full set.
source code
 
partial_to_all_subset_indices(subsets, base=0)
Takes a sequence of bools and generates it into an array of indices to be used to insert the subset into the full set.
source code
 
normalize(v) source code
 
sign(x) source code
 
find_matching_vertices_along_axis(axis, points_a, points_b, numbers_a, numbers_b) source code
 
orthonormalize(vectors, discard_threshold=None)
Carry out a modified [1] Gram-Schmidt orthonormalization on vectors.
source code
 
permutation_matrix(to_indices=None, from_indices=None, h=None, w=None, dtype=None, flavor=None)
Return a permutation matrix.
source code
 
leftsolve(A, B) source code
 
unit_vector(n, i, dtype=None)
Return the i-th unit vector of size n, with the given dtype.
source code
 
estimate_order_of_convergence(abscissae, errors)
Assuming that abscissae and errors are connected by a law of the form
source code
 
mem_checkpoint(name=None)
Invoke the garbage collector and wait for a keypress.
source code
 
apply_index_map(imap, vector) source code
 
apply_inverse_index_map(imap, vector) source code
 
cuthill_mckee(graph)
Return a Cuthill-McKee ordering for the given graph.
source code
 
reverse_lookup_table(lut) source code
 
time_count_flop(func, timer, counter, flop_counter, flops, increment=1) source code
 
diff_rst_flops(discr) source code
 
diff_rescale_one_flops(discr) source code
 
mass_flops(discr) source code
 
lift_flops(fg) source code
 
gather_flops(discr) source code
 
count_dofs(vec) source code
 
make_lax_friedrichs_flux(wave_speed, state, flux_func, bdry_tags_and_states, strong) source code
 
wait_for_keypress(discr)
MPI-aware keypress wait
source code
 
get_rank(discr)
Rank query that works with and without MPI active.
source code
 
typedump(value, max_seq=5, special_handlers={}) source code
Variables [hide private]
  cross = SubsettableCrossProduct()
Function Details [hide private]

cyl_bessel_j(...)

 

cyl_bessel_j( (object)arg1, (object)arg2, (object)arg3) -> float :

    C++ signature :
        double cyl_bessel_j(int,double,boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>)

cyl_neumann(...)

 

cyl_neumann( (object)arg1, (object)arg2, (object)arg3) -> float :

    C++ signature :
        double cyl_neumann(int,double,boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>)

log_shape(array)

source code 

Returns the "logical shape" of the array.

The "logical shape" is the shape that's left when the node-depending dimension has been eliminated.

levi_civita(tuple)

source code 

Compute an entry of the Levi-Civita tensor for the indices tuple.

Only three-tuples are supported for now.

full_to_subset_indices(subset, base=0)

source code 

Takes a sequence of bools and turns it into an array of indices to be used to extract the subset from the full set.

Example:

>>> full_to_subset_indices([False, True, True])
array([1 2])

full_to_all_subset_indices(subsets, base=0)

source code 

Takes a sequence of bools and generates it into an array of indices to be used to extract the subset from the full set.

Example:

>>> list(full_to_all_subset_indices([[False, True, True], [True,False,True]]))
[array([1 2]), array([3 5]

partial_to_all_subset_indices(subsets, base=0)

source code 

Takes a sequence of bools and generates it into an array of indices to be used to insert the subset into the full set.

Example:

>>> list(partial_to_all_subset_indices([[False, True, True], [True,False,True]]))
[array([0 1]), array([2 3]

orthonormalize(vectors, discard_threshold=None)

source code 

Carry out a modified [1] Gram-Schmidt orthonormalization on vectors.

If, during orthonormalization, the 2-norm of a vector drops below discard_threshold, then this vector is silently discarded. If discard_threshold is None, then no vector will ever be dropped, and a zero 2-norm encountered during orthonormalization will throw a RuntimeError.

[1] http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process

permutation_matrix(to_indices=None, from_indices=None, h=None, w=None, dtype=None, flavor=None)

source code 

Return a permutation matrix.

If to_indices is specified, the resulting permutation matrix P satisfies the condition

P * e[i] = e[to_indices[i]] for i=1,...,len(to_indices)

where e[i] is the i-th unit vector. The height of P is determined either implicitly by the maximum of to_indices or explicitly by the parameter h.

If from_indices is specified, the resulting permutation matrix P satisfies the condition

P * e[from_indices[i]] = e[i] for i=1,...,len(from_indices)

where e[i] is the i-th unit vector. The width of P is determined either implicitly by the maximum of from_indices of explicitly by the parameter w.

If both to_indices and from_indices is specified, a ValueError exception is raised.

estimate_order_of_convergence(abscissae, errors)

source code 

Assuming that abscissae and errors are connected by a law of the form

error = constant * abscissa ^ (-order),

this function finds, in a least-squares sense, the best approximation of constant and order for the given data set. It returns a tuple (constant, order). Both inputs must be PyLinear vectors.

cuthill_mckee(graph)

source code 

Return a Cuthill-McKee ordering for the given graph.

See (for example) Y. Saad, Iterative Methods for Sparse Linear System, 2nd edition, p. 76.

`graph' is given as an adjacency mapping, i.e. each node is mapped to a list of its neighbors.