1.The array module is kind of one of those things that you probably don't have a need for if you don't know why you would use it (and take note that I'm not trying to say that in a condescending manner!). Most of the time, the array module is used to interface with C code. To give you a more direct answer to your question about performance: Arrays are more efficient than lists for some uses. If you need to allocate an array that you KNOW will not change, then arrays can be faster and use less memory. GvR has an optimization anecdote in which the array module comes out to be the winner (long read, but worth it).On the other hand, part of the reason why lists eat up more memory than arrays is because python will allocate a few extra elements when all allocated elements get used. This means that appending items to lists is faster. So if you plan on adding items, a list is the way to go . From: http://stackoverflow.com/questions/176011/python-list-vs-array-when-to-use#178590 If you're going to perform arithmetic functions to your lists, you should really be using arrays instead. Additionally, arrays will store your data more compactly and efficiently, so if you're storing a large amount of data, you may consider using arrays as wel l. From: http://pythoncentral.io/the-difference-between-a-list-and-an-array/ Summray: For element appending, a list is more efficient; For storing a large amount of data with the certain length, and arrary will be faster and less memory. Additionaly, array is suitable for number calculation 2. The differences between the aray module and Numpy array: If all you're doing is creating arrays of simple data types and doing I/O, the array module will do just fine. On the other hand, you want to do any kind of numerical calculations, the array module doesn't provide any help with that. NumPy (and SciPy ) give you a wide variety of operations between arrays and special functions that are useful not only for scientific work but for things like advanced image manipulation or in general anything where you need to perform efficient calculations with large amounts of data. Numpy is also much more flexible, e.g. it supports arrays of any type of Python objects,
There are two ways to refer to the elements of a cell array: Enclose indices in smooth parentheses, () , to refer to sets of cells —for example, to define a subset of the array; Enclose indices in curly braces, {} , to refer to the text, numbers, or other data within individual cells . Curly braces are used in cell array assignment statements. C= { 'one', 'two', 'three'; 1, 2, 3 } ; % C 2X3 cell C= 'one' 'two' 'three' C ( 1,2 ) ans= 'two' % ans 1X1 cell C { 2,1 } ans= 1 % ans is a number C { 1,2 } ans= 'two' % ans str
X=1; Y= ; Z= ; E= 1 row, 1 column sz_Y=size(Y); - 1 3 % 1 row, 3 column sz_Z=size(Z); - 3 2 % 3 row, 2 column sz_Z=size(E); - 0 0 % % length returns a scalar describing the largest dimension of an array. len_X=length(X); - 1 len_Y=length(Y); - 3 % For vectors, the length is simply the number of the elements. len_Z=length(Z); - 3 % For arrays with more dimensions, length(Z) is max(size(Z)) .
FORTRAN中的数组声明可以有如下几种类型:Explicit-shape Array, Assumed-shape Array, Assumed-size Array, and Deferred-size Array Explicit-shape array: An explicit-shape array is declared with explicit values for the bounds in each dimension of the array(显式指定数组各维的上下界) . http://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/fortran-mac/GUID-1071BCFF-5A84-4CA9-B296-CB1BD5571777.htm#GUID-1071BCFF-5A84-4CA9-B296-CB1BD5571777 Both automatic array and adjustable array are explicit-shape arrays. Automatic Array: an automatic array is an explicit shape array that is a local variable. Automaticarrays are only allowed in function and subroutine subprograms, and are declared in the specification part of the subprogram. At least one bound of an automatic array must be a nonconstant specification expression. The bounds are determined when the subprogram is called. (自动数组是子程序的局地变量,在子程序内部声明,数组维数中至少一维由子程序的参数传递获得,其他维可在子程序中指定) Adjustable Array: a n adjustable array is an explicit shape array that is a dummy argument to a subprogram . At least one bound of an adjustable array must be a nonconstant specification expression. The bounds are determined when the subprogram is called. (局地可调数组是子程序的传递参数之一,同时可调数组维数中至少一维由子程序参数传递获得) Assumed-shape array : a n assumed-shape array is a dummy argument array that assumes the shape of its associated actual argument array(假定形状数组通常在子程序内部声明,指定维数/rank,但不指定维的大小 ) . http://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/fortran-mac/GUID-70941978-B44B-46CE-9156-67A02F23768E.htm#GUID-70941978-B44B-46CE-9156-67A02F23768E Assumed-size array : a n assumed-size array is a dummy argument array that assumes the size (only) of its associated actual argument array; the rank and extents can differ for the actual and dummy arrays(假定大小数组通常在子程序中声明,可以指定1维或多维的大小). http://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/fortran-mac/GUID-E094C9ED-8A70-4220-AA83-CBF957F7223C.htm#GUID-E094C9ED-8A70-4220-AA83-CBF957F7223C Deferred-shape array : a deferred-shape array is an array pointer or an allocatable array(递延形状数组指数组指针或可分配数组,数组的维数和各维大小在指针赋值时或使用allocate语句时获得). http://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/fortran-mac/GUID-885E4216-44C6-47B5-84D7-9F40CBF0008E.htm#GUID-885E4216-44C6-47B5-84D7-9F40CBF0008E 不同类型数组的存储结构不一样,比如Local Adjustable Array是stack array(栈型数组),而Deferred-shape array就是heap array (堆型数组)。stack的大小具有平台依赖性,因此程序中出现较大的局部数组时,可能会出现“segmentation fault”(即所谓的栈溢出,stack overflow),此时要么人为增加系统栈大小,要么将数组存储结构更改为堆结构。同时,两种数据结构在存取效率等多方面具有显著差异。 可参考: http://metman.info/blog/2013/08/12/fortransheng-ming-shu-zu-guo-da-wen-ti-jie-jue-ban-fa/ http://metman.info/blog/2013/05/31/segmentation-faultchan-sheng-gen-ben-yuan-yin/ http://bbs.csdn.net/topics/390147637
PROGRAM test IMPLICIT NONE INTEGER(kind=4), DIMENSION(:), POINTER :: a LOGICAL :: allocat INTEGER(kind=4) :: n = 10 allocat = .FALSE. IF (ASSOCIATED(a)) THEN IF (SIZE(a) /= n) THEN DEALLOCATE(a) allocat = .TRUE. END IF ELSE allocat = .TRUE. END IF WRITE(*,*) 'Size of a: ', SIZE(a) IF (allocat) THEN ALLOCATE(a(n)) END IF WRITE(*,*) 'Size of a: ', SIZE(a) DEALLOCATE(a) WRITE(*,*) 'Size of a: ', SIZE(a) END PROGRAM test
Halbach array From Wikipedia, the free encyclopedia Printable Version Cite this Page Ask a question Tweet this A Halbach array, showing the orientation of each piece's magnetic field. This array would give a strong field underneath, while the field above would cancel. A Halbach array is a special arrangement of permanent magnets that augments the magnetic field on one side of the array while cancelling the field to near zero on the other side. In the diagram, the magnetic field is enhanced on the bottom side and cancelled on the top side (a one-sided flux ). The rotating pattern of permanent magnets (on the front face; on the left, up, right, down) can be continued indefinitely and have the same effect. The effect of this arrangement is roughly similar to many horseshoe magnets placed adjacent to each other, with similar poles touching. The effect was discovered by Mallinson in 1973, and these 'one-sided flux' structures were initially described by him as a 'curiosity', although he recognised at the time the potential for significant improvements in magnetic tape technology. In the 1980s, the late Klaus Halbach, a physicist at Lawrence Livermore National Laboratory , invented the Halbach array to focus accelerator particle beams. Contents 1 Flat Halbach arrays 1.1 Magnetization 1.2 Applications 2 Halbach cylinder 2.1 Uniform fields 2.2 Varying the field 3 Halbach spheres 4 See also 5 References 6 External links // Flat Halbach arrays Magnetization Although this magnetic flux distribution seems somewhat counter-intuitive to those familiar with, for example, bar magnets or solenoids , the reason for this flux distribution can be intuitively visualised using Mallinson's original diagram (note this uses the negative y-component, unlike the diagram in Mallinson's paper). The diagram shows the field from a strip of ferromagnetic material with alternating magnetization in the y direction (top left) and in the x direction (top right). Note that the field above the plane is in the same direction for both structures, but the field below the plane is in opposite directions. The effect of superimposing both of these structures is shown in the figure at the bottom: The magnetic field around an infinite halbach array of cube magnets The crucial point is that the flux will cancel below the plane and reinforce itself above the plane . In fact, any magnetization pattern where the components of magnetization are out of phase with each other will result in a one-sided flux. The mathematical transform which shifts the phase of all components of some function by is called a Hilbert transform ; the components of the magnetization vector can therefore be any Hilbert transform pair (the simplest of which is simply , as shown in the diagram above). The advantages of one sided flux distributions are twofold: The field is twice as large on the side on which the flux is confined (in the idealised case). No stray field is produced (in the ideal, infinite length case) on the opposite side. This helps with field confinement, usually a problem in the design of magnetic structures. Halbach arrays can be rolled into a cylindrical shape, known as a Halbach cylinder . The field on the non cancelling side of a continuously varying infinite array is of the form: F ( x , y ) = F 0 e i k x e k y Where: is the field in the form is the magnitude of the field at the surface of the array is the spatial wavenumber , (i.e., the spatial frequency) Applications Although one-sided flux distributions may seem somewhat abstract, they have a surprising number of applications ranging from the humble refrigerator magnet through industrial applications such as the brushless AC motor and magnetic coupling, to high-tech applications such as wiggler magnets used in particle accelerators and free electron lasers . This device is also a key component of the Inductrack maglev system. The Halbach arrays repel buried loops of wire after they have been accelerated to speed, lifting the train. One-sided flux theory could also explain the lack of magnetic field on celestial bodies, such as the moon and Mars, due to the cooling process after the formation of such bodies freezing in , a spherical internal one-sided flux distribution, giving rise to zero field external to the planet. The simplest example of a one sided flux magnet is a refrigerator magnet. These are usually composed of powdered ferrite in a binder such as plastic or rubber. The extruded magnet is exposed to a rotating field giving the ferrite particles in the magnetic compound a magnetization resulting in a one-sided flux distribution. This distribution increases the holding force of the magnet when placed on a permeable surface, compared to the holding force from, say, a uniform magnetization of the magnetic compound. Fridge magnet flux distribution Scaling up this design and adding a top sheet gives a wiggler magnet, used in synchrotrons and free electron lasers . Wiggler magnets wiggle or oscillate an electron beam perpendicular to the magnetic field. As the electrons are undergoing acceleration they radiate electromagnetic energy and these photons can be trapped between two parallel mirrors that form a resonant cavity similar to that of a conventional laser. The design shown above is usually known as a Halbach wiggler. The magnetization vectors in the magnetized sheets rotate in the opposite senses to each other; above, the top sheet's magnetization vector rotates clockwise and the bottom sheet's magnetization vector rotates counter-clockwise. This design is chosen so that the x-components of the magnetic fields from the sheets cancel and the y-components reinforce so that the field is given by where k is the wavenumber of the magnetic sheet given by the spacing between magnetic blocks with the same magnetization vector. Halbach cylinder A Halbach cylinder is a magnetized cylinder composed of ferromagnetic material producing (in the idealised case) an intense magnetic field confined entirely within the cylinder with zero field outside. The cylinders can also be magnetized such that the magnetic field is entirely outside the cylinder, with zero field inside. Several magnetization distributions are shown below: The direction of magnetization within the ferromagnetic material is given by where M r is the ferromagnetic remanence (T/m). A choice of + k gives an internal magnetic field and - k gives an external magnetic field. Ideally, these structures would be created from an infinite length cylinder of magnetic material with the direction of magnetization continuously varying. The magnetic flux produced by this ideal design would be perfectly uniform and be entirely confined to the bore of the cylinder. Of course, the ideal case of infinite length is not realisable and in practice the finite length of the cylinders produces end effects which introduce non-uniformities in the field within the bore. The difficulty of manufacturing a cylinder with a continuously varying magnetization also usually leads to the design being broken into segments. These cylindrical structures are used in devices such as brushless AC motors, magnetic couplings and high field cylinders. Both brushless motors and coupling devices use multipole field arrangements: Brushless motors typically use cylindrical designs in which all the flux is confined to the centre of the bore (such as k = 4 above, a six pole rotor) with the AC coils also contained within the bore. Such self-shielding motors designs are more efficient and produce higher torque than conventional motor designs. Magnetic coupling devices transmit torque through magnetically transparent barriers (that is the barrier is non-magnetic or is magnetic but is not affected by an applied magnetic field), for instance between sealed containers or pressurised vessels. The optimal torque couplings consists of a pair of coaxially nested cylinders with opposite + k and - k flux magnetization patterns, as - k magnetization patterns produce fields entirely external to the cylinder. In the lowest energy state, the outer flux of the inner cylinder exactly matches the internal flux of the outer cylinder. Rotating one cylinder relative to the other from this state results in a restoring torque. Uniform fields Uniform field inside Halbach cylinder For the special case of k = 2 , the field inside the bore is uniform, and is given by: where the inner and outer cylinder radii are R o and R i , respectively. H is in the y direction. This is the simplest form of the Halbach cylinder, and it can be seen that if the ratio of outer to inner radii is greater than e the flux inside the bore actually exceeds the remanence of the magnetic material used to create the cylinder. This cylindrical design is only one class of design which produces a uniform field inside a cavity within an array of permanent magnets. Other classes of design include wedge designs, proposed by Abele and Jensen in which wedges of magnetized material are arranged to provide uniform field within cavities inside the design as shown below. The direction of magnetization of the wedges in (A) can be calculated using a set of rules given by Abele, and allows for great freedom in the shape of the cavity. Another class of design is the magnetic mangle (B), proposed by Coey and Cugat, in which uniformly magnetized rods are arranged such that their magnetization matches that of a Halbach cylinder, as shown for a six rod design. This design greatly increases access to the region of uniform field, at the expense of the volume of uniform field being smaller than in the cylindrical designs (although this area can be made larger by increasing the number of component rods). Rotating the rods relative to each other results in many possibilities including a dynamically variable field and various dipolar configurations. It can be seen that the designs shown in A and B are closely related to the k = 2 Halbach cylinder. Other very simple designs for a uniform field include separated magnets with soft iron return paths, as shown in figure (C). If any Halbach cylinder is cut and unrolled flat, the resulting structure is a Halbach array. Varying the field Halbach cylinders give a static field. However cylinders can be nested, and by rotating one cylinder relative to the other, cancellation of the field and adjustment of the direction can be achieved. Halbach spheres The magnetic field in the centre of a halbach sphere can be particularly intense If the two dimensional magnetic distribution patterns of the Halbach cylinder are extended to three dimensions, the result is the Halbach sphere. These designs have an extremely uniform field within the interior of the design, as they are not affected by the 'end effects' prevalent in the finite length cylinder design. The magnitude of the uniform field for a sphere also increases to 4/3 the amount for the ideal cylindrical design with the same inner and outer radii. However, being spherical, access to the region of uniform field is usually restricted to a narrow hole at the top and bottom of the design. The equation for the field in a Halbach sphere is: Higher fields are possible by optimising the spherical design to take account of the fact that it is composed of point dipoles (and not line dipoles). This results in the stretching of the sphere to an elliptical shape and having a non-uniform distribution of magnetization over the component parts of the sphere. Using this method, as well as soft pole pieces within the design, 4.5 T in a working volume of 20mm 3 was achieved by Bloch et al. in 1998 and this was increased further to 5 T in 2000, although over a smaller working area of 0.05mm . As hard materials are temperature dependent, refrigeration of the entire magnet array can increase the field within the working area further as shown by Kumada et al. This group also reported development of a 5.16 T Halbach dipole cylinder in 2003. See also Supermagnet Permanent magnet Strong focusing Inductrack uses Halbach arrays to generate strong fields for maglev References ^ J.C. Mallinson, One-Sided Fluxes A Magnetic Curiosity? , IEEE Transactions on Magnetics , 9 , 678-682, 1973, doi:10.1109/TMAG.1973.1067714 ^ Magnetically levitated train takes flight ^ ^ J.C.Mallinson, H.Shute and D. Wilton, One-Sided Fluxes in Planar, Cylindrical and Spherical Magnetized Structures IEEE Transactions on Magnetics,36, 2,Mar 2000, doi:10.1109/20.825805 ^ Tip Magazine: Magnets, Markets, and Magic Cylinders The Industrial Physicist by Michael Coey and Denis Weaire ^ K. Halbach, Nuclear Instruments and Methods, 169 , 1, (1980), doi:10.1016/0029-554X(80)90094-4 J. M. D. Coey and T.R. N Mhochin, Permanent Magnets, High Magnetic Fields: Science and Technology, Volume 1 , ed. F. Herlach and N. Miura, World Scientific Publishing, p25 - 47 (2003) O. Cugat and F. Bloch, 4-Tesla Permanent Magnetic Flux Source, Proc. 15th International Workshop on Rare Earth Magnets and Their Applications , published by MAT INFO, Dresden 1998, p807 (1998) External links Skytran technology Passive levitation of a shaft Build a Halbach array Electric model aircraft motor Copyright Information This article is distributed under the Creative Commons Attribution/Share-Alike License . For information on the contributors, please see the original Wikipedia article .
Uses of Tiling Arrays Target Application mRNA gene expression changes transcript validation/discovery DNA sequencing; genotyping DNA CGH: copy number changes ChIP-enriched DNA Protein binding sites transcription factor binding sites DNA methylation sites histone modification sites (Ru-Fang Yeh, Fall 2007, BMI 209 - Statistical Methods in Bioinformatics: Case Studies) Some tools for tiling array: CisGenome An integrated tool for tiling array, ChIP-seq, genome and cis-regulatory element analysis http://biogibbs.stanford.edu/~jihk/CisGenome/index.htm Tutorial of CisGenome http://biogibbs.stanford.edu/~jihk/CisGenome/index_files/tutorial.htm Files of two types are required, bpmap file and cel file(affymetrix). They are used for intensitynormalization. Then the data are intergrated with genome annotation to retrieve the DNA sequences. Packages in R/Bioconductor tilingArray Transcript mapping with high-density oligonucleotide tiling arrays http://bioconductor.org/packages/2.6/bioc/html/tilingArray.html rMAT R implementation from MAT program to normalize and analyze tiling arrays and ChIP-chip data. http://bioconductor.org/packages/2.6/bioc/html/rMAT.html AffyTiling Easy extraction of individual probes in Affymetrix tiling arrays http://bioconductor.org/packages/2.6/bioc/html/AffyTiling.html BayesPeak Bayesian Analysis of ChIP-seq Data http://bioconductor.org/packages/2.6/bioc/html/BayesPeak.html ChIPpeakAnno Batch annotation of the peaks identified from either ChIP-seq or ChIP-chip experiments. http://bioconductor.org/packages/2.6/bioc/html/ChIPpeakAnno.html Starr Simple tiling array analysis of Affymetrix ChIP-chip data http://bioconductor.org/packages/2.6/bioc/html/Starr.html