<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="BatBigarray.Genarray.html"> <link rel="next" href="BatBigarray.Array2.html"> <link rel="Up" href="BatBigarray.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of class methods" rel=Appendix href="index_methods.html"> <link title="Index of classes" rel=Appendix href="index_classes.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="BatArray" rel="Chapter" href="BatArray.html"> <link title="BatAvlTree" rel="Chapter" href="BatAvlTree.html"> <link title="BatBase64" rel="Chapter" href="BatBase64.html"> <link title="BatBig_int" rel="Chapter" href="BatBig_int.html"> <link title="BatBigarray" rel="Chapter" href="BatBigarray.html"> <link title="BatBitSet" rel="Chapter" href="BatBitSet.html"> <link title="BatBool" rel="Chapter" href="BatBool.html"> <link title="BatBounded" rel="Chapter" href="BatBounded.html"> <link title="BatBuffer" rel="Chapter" href="BatBuffer.html"> <link title="BatCache" rel="Chapter" href="BatCache.html"> <link title="BatChar" rel="Chapter" href="BatChar.html"> <link title="BatCharParser" rel="Chapter" href="BatCharParser.html"> <link title="BatComplex" rel="Chapter" href="BatComplex.html"> <link title="BatConcurrent" rel="Chapter" href="BatConcurrent.html"> <link title="BatDeque" rel="Chapter" href="BatDeque.html"> <link title="BatDigest" rel="Chapter" href="BatDigest.html"> <link title="BatDllist" rel="Chapter" href="BatDllist.html"> <link title="BatDynArray" rel="Chapter" href="BatDynArray.html"> <link title="BatEnum" rel="Chapter" href="BatEnum.html"> <link title="BatFile" rel="Chapter" href="BatFile.html"> <link title="BatFingerTree" rel="Chapter" href="BatFingerTree.html"> <link title="BatFloat" rel="Chapter" href="BatFloat.html"> <link title="BatFormat" rel="Chapter" href="BatFormat.html"> <link title="BatGc" rel="Chapter" href="BatGc.html"> <link title="BatGenlex" rel="Chapter" href="BatGenlex.html"> <link title="BatGlobal" rel="Chapter" href="BatGlobal.html"> <link title="BatHashcons" rel="Chapter" href="BatHashcons.html"> <link title="BatHashtbl" rel="Chapter" href="BatHashtbl.html"> <link title="BatHeap" rel="Chapter" href="BatHeap.html"> <link title="BatIMap" rel="Chapter" href="BatIMap.html"> <link title="BatIO" rel="Chapter" href="BatIO.html"> <link title="BatISet" rel="Chapter" href="BatISet.html"> <link title="BatInnerIO" rel="Chapter" href="BatInnerIO.html"> <link title="BatInnerPervasives" rel="Chapter" href="BatInnerPervasives.html"> <link title="BatInnerWeaktbl" rel="Chapter" href="BatInnerWeaktbl.html"> <link title="BatInt" rel="Chapter" href="BatInt.html"> <link title="BatInt32" rel="Chapter" href="BatInt32.html"> <link title="BatInt64" rel="Chapter" href="BatInt64.html"> <link title="BatInterfaces" rel="Chapter" href="BatInterfaces.html"> <link title="BatLazyList" rel="Chapter" href="BatLazyList.html"> <link title="BatLexing" rel="Chapter" href="BatLexing.html"> <link title="BatList" rel="Chapter" href="BatList.html"> <link title="BatLog" rel="Chapter" href="BatLog.html"> <link title="BatLogger" rel="Chapter" href="BatLogger.html"> <link title="BatMap" rel="Chapter" href="BatMap.html"> <link title="BatMarshal" rel="Chapter" href="BatMarshal.html"> <link title="BatMultiMap" rel="Chapter" href="BatMultiMap.html"> <link title="BatMultiPMap" rel="Chapter" href="BatMultiPMap.html"> <link title="BatMutex" rel="Chapter" href="BatMutex.html"> <link title="BatNativeint" rel="Chapter" href="BatNativeint.html"> <link title="BatNum" rel="Chapter" href="BatNum.html"> <link title="BatNumber" rel="Chapter" href="BatNumber.html"> <link title="BatOo" rel="Chapter" href="BatOo.html"> <link title="BatOptParse" rel="Chapter" href="BatOptParse.html"> <link title="BatOption" rel="Chapter" href="BatOption.html"> <link title="BatOrd" rel="Chapter" href="BatOrd.html"> <link title="BatParserCo" rel="Chapter" href="BatParserCo.html"> <link title="BatPathGen" rel="Chapter" href="BatPathGen.html"> <link title="BatPervasives" rel="Chapter" href="BatPervasives.html"> <link title="BatPrintexc" rel="Chapter" href="BatPrintexc.html"> <link title="BatPrintf" rel="Chapter" href="BatPrintf.html"> <link title="BatQueue" rel="Chapter" href="BatQueue.html"> <link title="BatRMutex" rel="Chapter" href="BatRMutex.html"> <link title="BatRandom" rel="Chapter" href="BatRandom.html"> <link title="BatRef" rel="Chapter" href="BatRef.html"> <link title="BatRefList" rel="Chapter" href="BatRefList.html"> <link title="BatResult" rel="Chapter" href="BatResult.html"> <link title="BatReturn" rel="Chapter" href="BatReturn.html"> <link title="BatScanf" rel="Chapter" href="BatScanf.html"> <link title="BatSeq" rel="Chapter" href="BatSeq.html"> <link title="BatSet" rel="Chapter" href="BatSet.html"> <link title="BatSplay" rel="Chapter" href="BatSplay.html"> <link title="BatStack" rel="Chapter" href="BatStack.html"> <link title="BatStream" rel="Chapter" href="BatStream.html"> <link title="BatString" rel="Chapter" href="BatString.html"> <link title="BatSubstring" rel="Chapter" href="BatSubstring.html"> <link title="BatSys" rel="Chapter" href="BatSys.html"> <link title="BatText" rel="Chapter" href="BatText.html"> <link title="BatTuple" rel="Chapter" href="BatTuple.html"> <link title="BatUChar" rel="Chapter" href="BatUChar.html"> <link title="BatUTF8" rel="Chapter" href="BatUTF8.html"> <link title="BatUnit" rel="Chapter" href="BatUnit.html"> <link title="BatUnix" rel="Chapter" href="BatUnix.html"> <link title="BatUref" rel="Chapter" href="BatUref.html"> <link title="BatVect" rel="Chapter" href="BatVect.html"> <link title="Batteries" rel="Chapter" href="Batteries.html"> <link title="BatteriesConfig" rel="Chapter" href="BatteriesConfig.html"> <link title="BatteriesPrint" rel="Chapter" href="BatteriesPrint.html"> <link title="BatteriesThread" rel="Chapter" href="BatteriesThread.html"> <link title="Extlib" rel="Chapter" href="Extlib.html"><link title="Unsafe operations" rel="Section" href="#6_Unsafeoperations"> <title>Batteries user guide : BatBigarray.Array1</title> </head> <body> <div class="navbar"><a class="pre" href="BatBigarray.Genarray.html" title="BatBigarray.Genarray">Previous</a> <a class="up" href="BatBigarray.html" title="BatBigarray">Up</a> <a class="post" href="BatBigarray.Array2.html" title="BatBigarray.Array2">Next</a> </div> <h1>Module <a href="type_BatBigarray.Array1.html">BatBigarray.Array1</a></h1> <pre><span class="keyword">module</span> Array1: <code class="code"><span class="keyword">sig</span></code> <a href="BatBigarray.Array1.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top"> One-dimensional arrays. The <code class="code"><span class="constructor">Array1</span></code> structure provides operations similar to those of <code class="code"><span class="constructor">Bigarray</span>.<span class="constructor">Genarray</span></code>, but specialized to the case of one-dimensional arrays. (The <code class="code"><span class="constructor">Array2</span></code> and <code class="code"><span class="constructor">Array3</span></code> structures below provide operations specialized for two- and three-dimensional arrays.) Statically knowing the number of dimensions of the array allows faster operations, and more precise static type-checking.<br> </div> <hr width="100%"> <pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">('a, 'b, 'c)</code> t</span> = <code class="type">('a, 'b, 'c) Bigarray.Array1.t</code> </pre> <div class="info "> The type of one-dimensional big arrays whose elements have OCaml type <code class="code"><span class="keywordsign">'</span>a</code>, representation kind <code class="code"><span class="keywordsign">'</span>b</code>, and memory layout <code class="code"><span class="keywordsign">'</span>c</code>.<br> </div> <pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type">('a, 'b) <a href="BatBigarray.html#TYPEkind">BatBigarray.kind</a> -><br> 'c <a href="BatBigarray.html#TYPElayout">BatBigarray.layout</a> -> int -> ('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a></code></pre><div class="info "> <code class="code"><span class="constructor">Array1</span>.create kind layout dim</code> returns a new bigarray of one dimension, whose size is <code class="code">dim</code>. <code class="code">kind</code> and <code class="code">layout</code> determine the array element kind and the array layout as described for <code class="code"><span class="constructor">Genarray</span>.create</code>.<br> </div> <pre><span id="VALdim"><span class="keyword">val</span> dim</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> int</code></pre><div class="info "> Return the size (dimension) of the given one-dimensional big array.<br> </div> <pre><span id="VALkind"><span class="keyword">val</span> kind</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> ('a, 'b) <a href="BatBigarray.html#TYPEkind">BatBigarray.kind</a></code></pre><div class="info "> Return the kind of the given big array.<br> </div> <pre><span id="VALlayout"><span class="keyword">val</span> layout</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> 'c <a href="BatBigarray.html#TYPElayout">BatBigarray.layout</a></code></pre><div class="info "> Return the layout of the given big array.<br> </div> <pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> int -> 'a</code></pre><div class="info "> <code class="code"><span class="constructor">Array1</span>.get a x</code>, or alternatively <code class="code">a.{x}</code>, returns the element of <code class="code">a</code> at index <code class="code">x</code>. <code class="code">x</code> must be greater or equal than <code class="code">0</code> and strictly less than <code class="code"><span class="constructor">Array1</span>.dim a</code> if <code class="code">a</code> has C layout. If <code class="code">a</code> has Fortran layout, <code class="code">x</code> must be greater or equal than <code class="code">1</code> and less or equal than <code class="code"><span class="constructor">Array1</span>.dim a</code>.<br> <b>Raises</b> <code>Invalid_argument</code> otherwise.<br> </div> <pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> int -> 'a -> unit</code></pre><div class="info "> <code class="code"><span class="constructor">Array1</span>.set a x v</code>, also written <code class="code">a.{x} <- v</code>, stores the value <code class="code">v</code> at index <code class="code">x</code> in <code class="code">a</code>. <code class="code">x</code> must be inside the bounds of <code class="code">a</code> as described in <code class="code"><span class="constructor">Bigarray</span>.<span class="constructor">Array1</span>.get</code>;<br> <b>Raises</b> <code>Invalid_argument</code> otherwise.<br> </div> <pre><span id="VALsub"><span class="keyword">val</span> sub</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -><br> int -> int -> ('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a></code></pre><div class="info "> Extract a sub-array of the given one-dimensional big array. See <code class="code"><span class="constructor">Genarray</span>.sub_left</code> for more details.<br> </div> <pre><span id="VALblit"><span class="keyword">val</span> blit</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -><br> ('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Copy the first big array to the second big array. See <code class="code"><span class="constructor">Genarray</span>.blit</code> for more details.<br> </div> <pre><span id="VALfill"><span class="keyword">val</span> fill</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> 'a -> unit</code></pre><div class="info "> Fill the given big array with the given value. See <code class="code"><span class="constructor">Genarray</span>.fill</code> for more details.<br> </div> <pre><span id="VALof_array"><span class="keyword">val</span> of_array</span> : <code class="type">('a, 'b) <a href="BatBigarray.html#TYPEkind">BatBigarray.kind</a> -><br> 'c <a href="BatBigarray.html#TYPElayout">BatBigarray.layout</a> -> 'a array -> ('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a></code></pre><div class="info "> Build a one-dimensional big array initialized from the given array.<br> </div> <pre><span id="VALmap_file"><span class="keyword">val</span> map_file</span> : <code class="type">Unix.file_descr -><br> ?pos:int64 -><br> ('a, 'b) <a href="BatBigarray.html#TYPEkind">BatBigarray.kind</a> -><br> 'c <a href="BatBigarray.html#TYPElayout">BatBigarray.layout</a> -> bool -> int -> ('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a></code></pre><div class="info "> Memory mapping of a file as a one-dimensional big array. See <code class="code"><span class="constructor">Bigarray</span>.<span class="constructor">Genarray</span>.map_file</code> for more details.<br> </div> <pre><span id="VALenum"><span class="keyword">val</span> enum</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> 'a <a href="BatEnum.html#TYPEt">BatEnum.t</a></code></pre><div class="info "> <code class="code"><span class="constructor">Array1</span>.enum e</code> returns an enumeration on the elements of <code class="code">e</code>. Contrarily to the multi-dimensional case, order of elements is specified: elements are in sequential order, from smaller to larger indices.<br> </div> <pre><span id="VALof_enum"><span class="keyword">val</span> of_enum</span> : <code class="type">('a, 'b) <a href="BatBigarray.html#TYPEkind">BatBigarray.kind</a> -><br> 'c <a href="BatBigarray.html#TYPElayout">BatBigarray.layout</a> -> 'a <a href="BatEnum.html#TYPEt">BatEnum.t</a> -> ('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a></code></pre><div class="info "> <code class="code"><span class="constructor">Array1</span>.of_enum kind layout enum</code> returns a new one-dimensional big array of kind <code class="code">kind</code> and layout <code class="code">layout</code>, with elements taken from the enumeration <code class="code">enum</code> in order.<br> <b>Since</b> 2.1<br> </div> <pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">('a -> 'b) -><br> ('b, 'c) Bigarray.kind -><br> ('a, 'd, 'e) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> ('b, 'c, 'e) <a href="BatBigarray.Array1.html#TYPEt">t</a></code></pre><div class="info "> <code class="code"><span class="constructor">Array1</span>.map f a</code> applies function <code class="code">f</code> to all the elements of <code class="code">a</code>, and builds a <code class="code"><span class="constructor">Bigarray</span>.<span class="constructor">Array1</span>.t</code> with the results returned by <code class="code">f</code>.<br> </div> <pre><span id="VALmapi"><span class="keyword">val</span> mapi</span> : <code class="type">(int -> 'a -> 'b) -><br> ('b, 'c) Bigarray.kind -><br> ('a, 'd, 'e) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> ('b, 'c, 'e) <a href="BatBigarray.Array1.html#TYPEt">t</a></code></pre><div class="info "> Same as <code class="code"><span class="constructor">Bigarray</span>.<span class="constructor">Array1</span>.map</code>, but the function is applied to the index of the element as the first argument, and the element itself as the second argument.<br> </div> <pre><span id="VALmodify"><span class="keyword">val</span> modify</span> : <code class="type">('a -> 'a) -> ('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> unit</code></pre><div class="info "> <code class="code">modify f a</code> changes each element <code class="code">x</code> in <code class="code">a</code> to <code class="code">f x</code> in-place.<br> </div> <pre><span id="VALmodifyi"><span class="keyword">val</span> modifyi</span> : <code class="type">(int -> 'a -> 'a) -> ('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> unit</code></pre><div class="info "> Same as <code class="code"><span class="constructor">Bigarray</span>.<span class="constructor">Array1</span>.modify</code>, but the function is applied to the index of the element as the first argument, and the element itself as the second argument.<br> </div> <pre><span id="VALto_array"><span class="keyword">val</span> to_array</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> 'a array</code></pre><div class="info "> Build a one-dimensional array initialized from the given big array.<br> </div> <br> <h6 id="6_Unsafeoperations">Unsafe operations</h6> <p> In case of doubt, don't use them.<br> <pre><span id="VALunsafe_get"><span class="keyword">val</span> unsafe_get</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> int -> 'a</code></pre><div class="info "> Like <code class="code"><span class="constructor">Bigarray</span>.<span class="constructor">Array1</span>.get</code>, but bounds checking is not always performed. Use with caution and only when the program logic guarantees that the access is within bounds.<br> </div> <pre><span id="VALunsafe_set"><span class="keyword">val</span> unsafe_set</span> : <code class="type">('a, 'b, 'c) <a href="BatBigarray.Array1.html#TYPEt">t</a> -> int -> 'a -> unit</code></pre><div class="info "> Like <code class="code"><span class="constructor">Bigarray</span>.<span class="constructor">Array1</span>.set</code>, but bounds checking is not always performed. Use with caution and only when the program logic guarantees that the access is within bounds.<br> </div> </body></html>