The Julia standard library contains a range of functions and macros appropriate for performing scientific and numerical computing, but as broad as many general purpose programming languages. Additional functionality is available from a growing collection of Available Packages. Functions are grouped by topic below.
Some general notes:
Quit (or control-D at the prompt). The default exit code is zero, indicating that the processes completed successfully.
Calls exit(0).
Register a zero-argument function to be called at exit.
Determine whether Julia is running an interactive session.
Print information about global variables in a module, optionally restricted to those matching pattern.
Edit a file optionally providing a line number to edit at. Returns to the julia prompt when you quit the editor.
Edit the definition of a function, optionally specifying a tuple of types to indicate which method to edit.
Show a file using the default pager, optionally providing a starting line number. Returns to the julia prompt when you quit the pager.
Show the definition of a function using the default pager, optionally specifying a tuple of types to indicate which method to see.
Send a printed form of x to the operating system clipboard (“copy”).
Return the contents of the operating system clipboard (“paste”).
Load source files once, in the context of the Main module, on every active node, searching the system-wide LOAD_PATH for files. require is considered a top-level operation, so it sets the current include path but does not use it to search for files (see help for include). This function is typically used to load library code, and is implicitly called by using to load packages.
Like require, except forces loading of files regardless of whether they have been loaded before. Typically used when interactively developing libraries.
Evaluate the contents of a source file in the current context. During including, a task-local include path is set to the directory containing the file. Nested calls to include will search relative to that path. All paths refer to files on node 1 when running in parallel, and files will be fetched from node 1. This function is typically used to load source interactively, or to combine files in packages that are broken into multiple source files.
Like include, except reads code from the given string rather than from a file. Since there is no file path involved, no path processing or fetching from node 1 is done.
Get help for a function. name can be an object or a string.
Search documentation for functions related to string.
Show which method of f will be called for the given arguments.
Evaluates the arguments to the function call, determines their types, and calls the which function on the resulting expression
Show all methods of f with their argument types.
Show all methods with an argument of type typ. If optional showparents is true, also show arguments with a parent type of typ, excluding type Any.
Show an expression and result, returning the result
Print information about the version of Julia in use. If the verbose argument is true, detailed system information is shown as well.
Determine whether x and y are identical, in the sense that no program could distinguish them. Compares mutable objects by address in memory, and compares immutable objects (such as numbers) by contents at the bit level. This function is sometimes called egal. The === operator is an alias for this function.
Determine whether x is of the given type.
True if and only if x and y have the same contents. Loosely speaking, this means x and y would look the same when printed. This is the default comparison function used by hash tables (Dict). New types with a notion of equality should implement this function, except for numbers, which should implement == instead. However, numeric types with special values might need to implement isequal as well. For example, floating point NaN values are not ==, but are all equivalent in the sense of isequal. Numbers of different types are considered unequal. Mutable containers should generally implement isequal by calling isequal recursively on all contents.
Test whether x is less than y. Provides a total order consistent with isequal. Values that are normally unordered, such as NaN, are ordered in an arbitrary but consistent fashion. This is the default comparison used by sort. Non-numeric types that can be ordered should implement this function. Numeric types only need to implement it if they have special values such as NaN.
Return x if condition is true, otherwise return y. This differs from ? or if in that it is an ordinary function, so all the arguments are evaluated first.
Compare x and y lexicographically and return -1, 0, or 1 depending on whether x is less than, equal to, or greater than y, respectively. This function should be defined for lexicographically comparable types, and lexless will call lexcmp by default.
Determine whether x is lexicographically less than y.
Get the concrete type of x.
Construct a tuple of the given objects.
Create a tuple of length n, computing each element as f(i), where i is the index of the element.
Get a unique integer id for x. object_id(x)==object_id(y) if and only if is(x,y).
Compute an integer hash code such that isequal(x,y) implies hash(x)==hash(y).
Register a function f(x) to be called when there are no program-accessible references to x. The behavior of this function is unpredictable if x is of a bits type.
Create a shallow copy of x: the outer structure is copied, but not all internal values. For example, copying an array produces a new array with identically-same elements as the original.
Create a deep copy of x: everything is copied recursively, resulting in a fully independent object. For example, deep-copying an array produces a new array whose elements are deep-copies of the original elements.
As a special case, functions can only be actually deep-copied if they are anonymous, otherwise they are just copied. The difference is only relevant in the case of closures, i.e. functions which may contain hidden internal references.
While it isn’t normally necessary, user-defined types can override the default deepcopy behavior by defining a specialized version of the function deepcopy_internal(x::T, dict::ObjectIdDict) (which shouldn’t otherwise be used), where T is the type to be specialized for, and dict keeps track of objects copied so far within the recursion. Within the definition, deepcopy_internal should be used in place of deepcopy, and the dict variable should be updated as appropriate before returning.
Tests whether an assignable location is defined. The arguments can be an array and index, a composite object and field name (as a symbol), or a module and a symbol.
Try to convert x to the given type. Conversions from floating point to integer, rational to integer, and complex to real will raise an InexactError if x cannot be represented exactly in the new type.
Convert all arguments to their common promotion type (if any), and return them all (as a tuple).
Convert y to the type of x.
The identity function. Returns its argument.
Return the supertype of DataType T
True if and only if all values of type1 are also of type2. Can also be written using the <: infix operator as type1 <: type2.
Subtype operator, equivalent to issubtype(T1,T2).
Return a list of immediate subtypes of DataType T. Note that all currently loaded subtypes are included, including those not visible in the current module.
Return a nested list of all subtypes of DataType T. Note that all currently loaded subtypes are included, including those not visible in the current module.
The lowest value representable by the given (real) numeric type.
The highest value representable by the given (real) numeric type.
The smallest in absolute value non-subnormal value representable by the given floating-point type
The highest finite value representable by the given floating-point type
The largest integer losslessly representable by the given floating-point type
Size, in bytes, of the canonical binary representation of the given type, if any.
The distance between 1.0 and the next larger representable floating-point value of type. The only types that are sensible arguments are Float32 and Float64. If type is omitted, then eps(Float64) is returned.
The distance between x and the next larger representable floating-point value of the same type as x.
Determine a type big enough to hold values of each argument type without loss, whenever possible. In some cases, where no type exists which to which both types can be promoted losslessly, some loss is tolerated; for example, promote_type(Int64,Float64) returns Float64 even though strictly, not all Int64 values can be represented exactly as Float64 values.
Specifies what type should be used by promote when given values of types type1 and type2. This function should not be called directly, but should have definitions added to it for new types as appropriate.
Extract a named field from a value of composite type. The syntax a.b calls getfield(a, :b), and the syntax a.(b) calls getfield(a, b).
Assign x to a named field in value of composite type. The syntax a.b = c calls setfield(a, :b, c), and the syntax a.(b) = c calls setfield(a, b, c).
The byte offset of each field of a type relative to the data start. For example, we could use it in the following manner to summarize information about a struct type:
structinfo(T) = [zip(fieldoffsets(T),names(T),T.types)...]
structinfo(Stat)
Determine the declared type of a named field in a value of composite type.
True if value v is immutable. See Immutable Composite Types for a discussion of immutability.
True if T is a “plain data” type, meaning it is immutable and contains no references to other values. Typical examples are numeric types such as Uint8, Float64, and Complex{Float64}.
Determine whether T is a concrete type that can have instances, meaning its only subtypes are itself and None (but T itself is not None).
Compute a type that contains both T and S.
Compute a type that contains the intersection of T and S. Usually this will be the smallest such type or one close to it.
Determine whether the given generic function has a method matching the given tuple of argument types.
Example: method_exists(length, (Array,)) = true
Determine whether the given generic function has a method applicable to the given arguments.
Invoke a method for the given generic function matching the specified types (as a tuple), on the specified arguments. The arguments must be compatible with the specified types. This allows invoking a method other than the most specific matching method, which is useful when the behavior of a more general definition is explicitly needed (often as part of the implementation of a more specific method of the same function).
Applies a function to the preceding argument which allows for easy function chaining.
Example: [1:5] |> x->x.^2 |> sum |> inv
Evaluate an expression and return the value.
Evaluate an expression and return the value.
Evaluate all expressions in the given file, and return the value of the last one. No other processing (path searching, fetching from node 1, etc.) is performed.
Only valid in the context of an Expr returned from a macro. Prevents the macro hygine pass from turning embedded variables into gensym variables. See the Macros section of the Metaprogramming chapter of the manual for more details and examples.
Generates a symbol which will not conflict with other variable names.
Generates a gensym symbol for a variable. For example, @gensym x y is transformed into x = gensym(“x”); y = gensym(“y”).
Parse the expression string and return an expression (which could later be passed to eval for execution). Start is the index of the first character to start parsing (default is 1). If greedy is true (default), parse will try to consume as much input as it can; otherwise, it will stop as soon as it has parsed a valid token. If raise is true (default), parse errors will raise an error; otherwise, parse will return the error as an expression object.
Sequential iteration is implemented by the methods start, done, and next. The general for loop:
for i = I
# body
end
is translated to:
state = start(I)
while !done(I, state)
(i, state) = next(I, state)
# body
end
The state object may be anything, and should be chosen appropriately for each iterable type.
Get initial iteration state for an iterable object
Test whether we are done iterating
For a given iterable object and iteration state, return the current item and the next iteration state
For a set of iterable objects, returns an iterable of tuples, where the ith tuple contains the ith component of each input iterable.
Note that zip is it’s own inverse: [zip(zip(a...)...)...] == [a...].
Return an iterator that yields (i, x) where i is an index starting at 1, and x is the ith value from the given iterator.
Fully implemented by: Range, Range1, NDRange, Tuple, Real, AbstractArray, IntSet, ObjectIdDict, Dict, WeakKeyDict, EachLine, String, Set, Task.
Determine whether a collection is empty (has no elements).
Remove all elements from a collection.
For ordered, indexable collections, the maximum index i for which getindex(collection, i) is valid. For unordered collections, the number of elements.
Returns the last index of the collection.
Example: endof([1,2,4]) = 3
Fully implemented by: Range, Range1, Tuple, Number, AbstractArray, IntSet, Dict, WeakKeyDict, String, Set.
Determine whether an item is in the given collection, in the sense that it is isequal to one of the values generated by iterating over the collection.
Determine the type of the elements generated by iterating collection. For associative collections, this will be a (key,value) tuple type.
Returns a vector containing the highest index in b for each value in a that is a member of b . The output vector contains 0 wherever a is not a member of b.
Returns the indices of elements in collection a that appear in collection b
Returns an array containing only the unique elements of the iterable itr, in the order that the first of each set of equivalent elements originally appears.
Reduce the given collection with the given operator, i.e. accumulate v = op(v,elt) for each element, where v starts as v0. Reductions for certain commonly-used operators are available in a more convenient 1-argument form: maximum(itr), minimum(itr), sum(itr), prod(itr), any(itr), all(itr).
The associativity of the reduction is implementation-dependent; if you need a particular associativity, e.g. left-to-right, you should write your own loop.
Returns the largest element in a collection
Compute the maximum value of an array over the given dimensions
Returns the smallest element in a collection
Compute the minimum value of an array over the given dimensions
Returns the index of the maximum element in a collection
Returns the index of the minimum element in a collection
Returns the maximum element and its index
Returns the minimum element and its index
Returns the sum of all elements in a collection
Sum elements of an array over the given dimensions.
Sum the results of calling function f on each element of itr.
Returns the product of all elements of a collection
Multiply elements of an array over the given dimensions.
Test whether any elements of a boolean collection are true
Test whether any values along the given dimensions of an array are true.
Test whether all elements of a boolean collection are true
Test whether all values along the given dimensions of an array are true.
Count the number of elements in itr for which predicate p is true.
Determine whether any element of itr satisfies the given predicate.
Determine whether all elements of itr satisfy the given predicate.
Transform collection c by applying f to each element.
Example: map((x) -> x * 2, [1, 2, 3]) = [2, 4, 6]
Applies function f to each element in itr and then reduces the result using the binary function op.
Example: mapreduce(x->x^2, +, [1:3]) == 1 + 4 + 9 == 14
The associativity of the reduction is implementation-dependent; if you need a particular associativity, e.g. left-to-right, you should write your own loop.
Get the first element of an iterable collection.
Get the last element of an ordered collection, if it can be computed in O(1) time. This is accomplished by calling endof to get the last index.
Get the step size of a Range object.
Return an array of all items in a collection. For associative collections, returns (key, value) tuples.
Return an array of type Array{element_type,1} of all items in a collection.
Determine whether every element of a is also in b, using the in function.
Return a copy of collection, removing elements for which function is false. For associative collections, the function is passed two arguments (key and value).
Update collection, removing elements for which function is false. For associative collections, the function is passed two arguments (key and value).
Retrieve the value(s) stored at the given key or index within a collection. The syntax a[i,j,...] is converted by the compiler to getindex(a, i, j, ...).
Store the given value at the given key or index within a collection. The syntax a[i,j,...] = x is converted by the compiler to setindex!(a, x, i, j, ...).
Fully implemented by: Array, DArray, BitArray, AbstractArray, SubArray, ObjectIdDict, Dict, WeakKeyDict, String.
Partially implemented by: Range, Range1, Tuple.
Dict is the standard associative collection. Its implementation uses the hash(x) as the hashing function for the key, and isequal(x,y) to determine equality. Define these two functions for custom types to override how they are stored in a hash table.
ObjectIdDict is a special hash table where the keys are always object identities. WeakKeyDict is a hash table implementation where the keys are weak references to objects, and thus may be garbage collected even when referenced in a hash table.
Dicts can be created using a literal syntax: {"A"=>1, "B"=>2}. Use of curly brackets will create a Dict of type Dict{Any,Any}. Use of square brackets will attempt to infer type information from the keys and values (i.e. ["A"=>1, "B"=>2] creates a Dict{ASCIIString, Int64}). To explicitly specify types use the syntax: (KeyType=>ValueType)[...]. For example, (ASCIIString=>Int32)["A"=>1, "B"=>2].
As with arrays, Dicts may be created with comprehensions. For example, {i => f(i) for i = 1:10}.
Dict{K,V}() constructs a hashtable with keys of type K and values of type V. The literal syntax is {"A"=>1, "B"=>2} for a Dict{Any,Any}, or ["A"=>1, "B"=>2] for a Dict of inferred type.
Determine whether a collection has a mapping for a given key.
Return the value stored for the given key, or the given default value if no mapping for the key is present.
Return the key matching argument key if one exists in collection, otherwise return default.
Delete the mapping for the given key in a collection, and return the colection.
Delete and return the mapping for key if it exists in collection, otherwise return default, or throw an error if default is not specified.
Return an iterator over all keys in a collection. collect(keys(d)) returns an array of keys.
Return an iterator over all values in a collection. collect(values(d)) returns an array of values.
Construct a merged collection from the given collections.
Update collection with pairs from the other collections
Suggest that collection s reserve capacity for at least n elements. This can improve performance.
Fully implemented by: ObjectIdDict, Dict, WeakKeyDict.
Partially implemented by: IntSet, Set, EnvHash, Array, BitArray.
Add an element to a set-like collection.
Construct a Set with the given elements. Should be used instead of IntSet for sparse integer sets, or for sets of arbitrary objects.
Construct a sorted set of the given integers. Implemented as a bit string, and therefore designed for dense integer sets. If the set will be sparse (for example holding a single very large integer), use Set instead.
Construct the union of two or more sets. Maintains order with arrays.
Union each element of iterable into set s in-place.
Construct the intersection of two or more sets. Maintains order and multiplicity of the first argument for arrays and ranges.
Construct the set of elements in s1 but not s2. Maintains order with arrays.
Remove each element of iterable from set s in-place.
Construct the symmetric difference of elements in the passed in sets or arrays. Maintains order with arrays.
IntSet s is destructively modified to toggle the inclusion of integer n.
For each element in itr, destructively toggle its inclusion in set s.
Construct the symmetric difference of IntSets s1 and s2, storing the result in s1.
Returns the set-complement of IntSet s.
Mutates IntSet s into its set-complement.
Intersects IntSets s1 and s2 and overwrites the set s1 with the result. If needed, s1 will be expanded to the size of s2.
True if A ⊆ S (A is a subset of or equal to S)
Fully implemented by: IntSet, Set.
Partially implemented by: Array.
Insert an item at the end of a collection.
Remove the last item in a collection and return it.
Insert an item at the beginning of a collection.
Remove the first item in a collection.
Insert an item at the given index.
Remove the item at the given index, and return the removed item. Subsequent items are shifted down to fill the resulting gap. If specified, replacement values from an ordered collection will be spliced in place of the removed item.
Remove items in the specified index range, and return a collection containing the removed items. Subsequent items are shifted down to fill the resulting gap. If specified, replacement values from an ordered collection will be spliced in place of the removed items.
Resize collection to contain n elements.
Add the elements of items to the end of a collection. append!([1],[2,3]) => [1,2,3]
Insert the elements of items to the beginning of a collection. prepend!([3],[1,2]) => [1,2,3]
Fully implemented by: Vector (aka 1-d Array), BitVector (aka 1-d BitArray).
The number of characters in string s.
The number of bytes in string s.
Concatenate strings.
Example: "Hello " * "world" == "Hello world"
Repeat string s n times.
Example: "Julia "^3 == "Julia Julia Julia "
Create a string from any values using the print function.
Create a string from any value using the show function.
Create a string from the address of a C (0-terminated) string. A copy is made; the ptr can be safely freed.
Convert a string to a contiguous byte array representation appropriate for passing it to C functions.
Create an ASCII string from a byte array.
Convert a string to a contiguous ASCII string (all characters must be valid ASCII characters).
Create a UTF-8 string from a byte array.
Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters).
Returns true if the string or byte vector is valid ASCII, false otherwise.
Returns true if the string or byte vector is valid UTF-8, false otherwise.
Returns true if the given char or integer is a valid Unicode code point.
Test whether a string contains a match of the given regular expression.
Search for the first match of the regular expression r in s and return a RegexMatch object containing the match, or nothing if the match failed. The matching substring can be retrieved by accessing m.match and the captured sequences can be retrieved by accessing m.captures
Search for all matches of a the regular expression r in s and return a iterator over the matches. If overlap is true, the matching sequences are allowed to overlap indices in the original string, otherwise they must be from distinct character ranges.
Return a vector of the matching substrings from eachmatch.
Make a string at least n characters long by padding on the left with copies of p.
Make a string at least n characters long by padding on the right with copies of p.
Search for the first occurance of the given characters within the given string. The second argument may be a single character, a vector or a set of characters, a string, or a regular expression (though regular expressions are only allowed on contiguous strings, such as ASCII or UTF-8 strings). The third argument optionally specifies a starting index. The return value is a range of indexes where the matching sequence is found, such that s[search(s,x)] == x:
search(string, “substring”) = start:end such that string[start:end] == "substring", or 0:-1 if unmatched.
search(string, ‘c’) = index such that string[index] == 'c', or 0 if unmatched.
Similar to search, but returning the last occurance of the given characters within the given string, searching in reverse from start.
Similar to search, but return only the start index at which the substring is found, or 0 if it is not.
Similar to rsearch, but return only the start index at which the substring is found, or 0 if it is not.
Determine whether the second argument is a substring of the first.
Search for the given pattern pat, and replace each occurrence with r. If n is provided, replace at most n occurrences. As with search, the second argument may be a single character, a vector or a set of characters, a string, or a regular expression. If r is a function, each occurrence is replaced with r(s) where s is the matched substring.
Return an array of strings by splitting the given string on occurrences of the given character delimiters, which may be specified in any of the formats allowed by search‘s second argument (i.e. a single character, collection of characters, string, or regular expression). If chars is omitted, it defaults to the set of all space characters, and include_empty is taken to be false. The last two arguments are also optional: they are are a maximum size for the result and a flag determining whether empty fields should be included in the result.
Similar to split, but starting from the end of the string.
Return string with any leading and trailing whitespace removed. If a string chars is provided, instead remove characters contained in that string.
Return string with any leading whitespace removed. If a string chars is provided, instead remove characters contained in that string.
Return string with any trailing whitespace removed. If a string chars is provided, instead remove characters contained in that string.
Returns true if string starts with prefix.
Returns true if string ends with suffix.
Returns string with all characters converted to uppercase.
Returns string with all characters converted to lowercase.
Returns string with the first character converted to uppercase.
Returns string with the first character converted to lowercase.
Join an array of strings into a single string, inserting the given delimiter between adjacent strings.
Remove the last character from a string
Remove a trailing newline from a string
Convert a byte index to a character index
Convert a character index to a byte index
Tells whether index i is valid for the given string
Get the next valid string index after i. Returns endof(str)+1 at the end of the string.
Get the previous valid string index before i. Returns 0 at the beginning of the string.
Create a random ASCII string of length len, consisting of upper- and lower-case letters and the digits 0-9
Gives the number of columns needed to print a character.
Gives the number of columns needed to print a string.
Tests whether a character is alphanumeric, or whether this is true for all elements of a string.
Tests whether a character is alphabetic, or whether this is true for all elements of a string.
Tests whether a character belongs to the ASCII character set, or whether this is true for all elements of a string.
Tests whether a character is a tab or space, or whether this is true for all elements of a string.
Tests whether a character is a control character, or whether this is true for all elements of a string.
Tests whether a character is a numeric digit (0-9), or whether this is true for all elements of a string.
Tests whether a character is printable, and not a space, or whether this is true for all elements of a string.
Tests whether a character is a lowercase letter, or whether this is true for all elements of a string.
Tests whether a character is printable, including space, or whether this is true for all elements of a string.
Tests whether a character is printable, and not a space or alphanumeric, or whether this is true for all elements of a string.
Tests whether a character is any whitespace character, or whether this is true for all elements of a string.
Tests whether a character is an uppercase letter, or whether this is true for all elements of a string.
Tests whether a character is a valid hexadecimal digit, or whether this is true for all elements of a string.
Convert a string to a Symbol.
General escaping of traditional C and Unicode escape sequences. See print_escaped() for more general escaping.
General unescaping of traditional C and Unicode escape sequences. Reverse of escape_string(). See also print_unescaped().
Global variable referring to the standard out stream.
Global variable referring to the standard error stream.
Global variable referring to the standard input stream.
Open a file in a mode specified by five boolean arguments. The default is to open files for reading only. Returns a stream for accessing the file.
Alternate syntax for open, where a string-based mode specifier is used instead of the five booleans. The values of mode correspond to those from fopen(3) or Perl open, and are equivalent to setting the following boolean groups:
r | read |
r+ | read, write |
w | write, create, truncate |
w+ | read, write, create, truncate |
a | write, create, append |
a+ | read, write, create, append |
Apply the function f to the result of open(args...) and close the resulting file descriptor upon completion.
Example: open(readall, "file.txt")
Create an in-memory I/O stream.
Create a fixed size IOBuffer. The buffer will not grow dynamically.
Create a read-only IOBuffer on the data underlying the given string
Create an IOBuffer, which may optionally operate on a pre-existing array. If the readable/writable arguments are given, they restrict whether or not the buffer may be read from or written to respectively. By default the buffer is readable but not writable. The last argument optionally specifies a size beyond which the buffer may not be grown.
Obtain the contents of an IOBuffer as an array, without copying.
Obtain the contents of an IOBuffer as a string, without copying.
Create an IOStream object from an integer file descriptor. If own is true, closing this object will close the underlying descriptor. By default, an IOStream is closed when it is garbage collected. name allows you to associate the descriptor with a named file.
Commit all currently buffered writes to the given stream.
Flushes the C stdout and stderr streams (which may have been written to by external C code).
Close an I/O stream. Performs a flush first.
Write the canonical binary representation of a value to the given stream.
Read a value of the given type from a stream, in canonical binary representation.
Read a series of values of the given type from a stream, in canonical binary representation. dims is either a tuple or a series of integer arguments specifying the size of Array to return.
Read at most nb bytes from the stream into b, returning the number of bytes read (increasing the size of b as needed).
Read at most nb bytes from the stream, returning a Vector{Uint8} of the bytes read.
Get the current position of a stream.
Seek a stream to the given position.
Seek a stream to its beginning.
Seek a stream to its end.
Seek a stream relative to the current position.
Tests whether an I/O stream is at end-of-file. If the stream is not yet exhausted, this function will block to wait for more data if necessary, and then return false. Therefore it is always safe to read one byte after seeing eof return false. eof will return false as long as buffered data is still available, even if the remote end of a connection is closed.
Determine whether a stream is read-only.
Determine whether a stream is open (i.e. has not been closed yet). If the connection has been closed remotely (in case of e.g. a socket), isopen will return false even though buffered data may still be available. Use eof to check if necessary.
Converts the endianness of a value from Network byte order (big-endian) to that used by the Host.
Converts the endianness of a value from that used by the Host to Network byte order (big-endian).
Converts the endianness of a value from Little-endian to that used by the Host.
Converts the endianness of a value from that used by the Host to Little-endian.
The 32-bit byte-order-mark indicates the native byte order of the host machine. Little-endian machines will contain the value 0x04030201. Big-endian machines will contain the value 0x01020304.
Write an arbitrary value to a stream in an opaque format, such that it can be read back by deserialize. The read-back value will be as identical as possible to the original. In general, this process will not work if the reading and writing are done by different versions of Julia, or an instance of Julia with a different system image.
Read a value written by serialize.
General escaping of traditional C and Unicode escape sequences, plus any characters in esc are also escaped (with a backslash).
General unescaping of traditional C and Unicode escape sequences. Reverse of print_escaped().
Print elements of items to io with delim between them. If last is specified, it is used as the final delimiter instead of delim.
Print the shortest possible representation of number x as a floating point number, ensuring that it would parse to the exact same number.
Returns the file descriptor backing the stream or file. Note that this function only applies to synchronous File‘s and IOStream‘s not to any of the asynchronous streams.
Create a pipe to which all C and Julia level STDOUT output will be redirected. Returns a tuple (rd,wr) representing the pipe ends. Data written to STDOUT may now be read from the rd end of the pipe. The wr end is given for convenience in case the old STDOUT object was cached by the user and needs to be replaced elsewhere.
Replace STDOUT by stream for all C and julia level output to STDOUT. Note that stream must be a TTY, a Pipe or a TcpSocket.
Like redirect_stdout, but for STDERR
Like redirect_stdout, but for STDIN. Note that the order of the return tuple is still (rd,wr), i.e. data to be read from STDIN, may be written to wr.
Read the entirety of x as a string but remove trailing newlines. Equivalent to chomp(readall(x)).
Returns the files and directories in the directory dir (or the current working directory if not given).
Resize the file or buffer given by the first argument to exactly n bytes, filling previously unallocated space with ‘0’ if the file or buffer is grown
Advance the stream until before the first character for which predicate returns false. For example skipchars(stream, isspace) will skip all whitespace. If keyword argument linecomment is specified, characters from that character through the end of a line will also be skipped.
Read io until the end of the stream/file and count the number of non-empty lines. To specify a file pass the filename as the first argument. EOL markers other than ‘n’ are supported by passing them as the second argument.
An IOBuffer that allows reading and performs writes by appending. Seeking and truncating are not supported. See IOBuffer for the available constructors.
Create a PipeBuffer to operate on a data vector, optionally specifying a size beyond which the underlying Array may not be grown.
Read all available data on the stream, blocking the task only if no data is available.
Returns a structure whose fields contain information about the file. The fields of the structure are:
size | The size (in bytes) of the file |
device | ID of the device that contains the file |
inode | The inode number of the file |
mode | The protection mode of the file |
nlink | The number of hard links to the file |
uid | The user id of the owner of the file |
gid | The group id of the file owner |
rdev | If this file refers to a device, the ID of the device it refers to |
blksize | The file-system preffered block size for the file |
blocks | The number of such blocks allocated |
mtime | Unix timestamp of when the file was last modified |
ctime | Unix timestamp of when the file was created |
Like stat, but for symbolic links gets the info for the link itself rather than the file it refers to. This function must be called on a file path rather than a file object or a file descriptor.
Equivalent to stat(file).ctime
Equivalent to stat(file).mtime
Equivalent to stat(file).mode
Equivalent to stat(file).size
Gets the permissions of the owner of the file as a bitfield of
01 | Execute Permission |
02 | Write Permission |
04 | Read Permission |
For allowed arguments, see the stat method.
Like uperm but gets the permissions of the group owning the file
Like uperm but gets the permissions for people who neither own the file nor are a member of the group owning the file
Copy a file from src to dest.
Download a file from the given url, optionally renaming it to the given local file name. Note that this function relies on the availability of external tools such as curl, wget or fetch to download the file and is provided for convenience. For production use or situations in which more options are need, please use a package that provides the desired functionality instead.
Move a file from src to dst.
Delete the file at the given path. Note that this does not work on directories.
Update the last-modified timestamp on a file to the current time.
Connect to the host host on port port
Connect to the Named Pipe/Domain Socket at path
Listen on port on the address specified by addr. By default this listens on localhost only. To listen on all interfaces pass, IPv4(0) or IPv6(0) as appropriate.
Listens on/Creates a Named Pipe/Domain Socket
Gets the IP address of the host (may have to do a DNS lookup)
Parse a string specifying an IPv4 or IPv6 ip address.
Returns IPv4 object from ip address formatted as Integer
Returns IPv6 object from ip address formatted as Integer
Returns the number of bytes available for reading before a read from this stream or buffer will block.
Accepts a connection on the given server and returns a connection to the client. An uninitialized client stream may be provided, in which case it will be used instead of creating a new stream.
Create a TcpServer on any port, using hint as a starting point. Returns a tuple of the actual port that the server was created on and the server itself.
Watch file or directory s and run callback cb when s is modified. The poll parameter specifies whether to use file system event monitoring or polling. The callback function cb should accept 3 arguments: (filename, events, status) where filename is the name of file that was modified, events is an object with boolean fields changed and renamed when using file system event monitoring, or readable and writable when using polling, and status is always 0. Pass false for cb to not use a callback function.
Poll a file descriptor fd for changes in the read or write availability and with a timeout given by the second argument. If the timeout is not needed, use wait(fd) instead. The keyword arguments determine which of read and/or write status should be monitored and at least one of them needs to be set to true. The returned value is an object with boolean fields readable, writable, and timedout, giving the result of the polling.
Monitor a file for changes by polling every interval_seconds seconds for seconds seconds. A return value of true indicates the file changed, a return value of false indicates a timeout.
Write an informative text representation of a value to the current output stream. New types should overload show(io, x) where the first argument is a stream. The representation used by show generally includes Julia-specific formatting and type information.
Show a more compact representation of a value. This is used for printing array elements. If a new type has a different compact representation, it should overload showcompact(io, x) where the first argument is a stream.
Similar to show, except shows all elements of arrays.
Return a string giving a brief description of a value. By default returns string(typeof(x)). For arrays, returns strings like “2x2 Float64 Array”.
Write (to the default output stream) a canonical (un-decorated) text representation of a value if there is one, otherwise call show. The representation used by print includes minimal formatting and tries to avoid Julia-specific details.
Print strings in a color specified as a symbol, for example :red or :blue.
Display an informational message.
Display a warning.
Print arg(s) using C printf() style format specification string. Optionally, an IOStream may be passed as the first argument to redirect output.
Return @printf formatted output as string.
Call the given function with an I/O stream and the supplied extra arguments. Everything written to this I/O stream is returned as a string.
Show a descriptive representation of an exception object.
Show all user-visible structure of a value.
Show all structure of a value, including all fields of objects.
Read the entire contents of an I/O stream as a string.
Read a single line of text, including a trailing newline character (if one is reached before the end of the input).
Read a string, up to and including the given delimiter byte.
Read all lines as an array.
Create an iterable object that will yield each line from a stream.
Read a matrix from the source where each line gives one row, with elements separated by the given delimeter. The source can be a text file, stream or byte array. Memory mapped filed can be used by passing the byte array representation of the mapped segment as source.
If has_header is true the first row of data would be read as headers and the tuple (data_cells, header_cells) is returned instead of only data_cells.
If use_mmap is true the file specified by source is memory mapped for potential speedups.
If ignore_invalid_chars is true bytes in source with invalid character encoding will be ignored. Otherwise an error is thrown indicating the offending character position.
If all data is numeric, the result will be a numeric array. If some elements cannot be parsed as numbers, a cell array of numbers and strings is returned.
Read a matrix from the source with a given element type. If T is a numeric type, the result is an array of that type, with any non-numeric elements as NaN for floating-point types, or zero. Other useful values of T include ASCIIString, String, and Any.
Write an array to a text file using the given delimeter (defaults to comma).
Equivalent to readdlm with delim set to comma.
Equivalent to writedlm with delim set to comma.
Returns a new write-only I/O stream, which converts any bytes written to it into base64-encoded ASCII bytes written to ostream. Calling close on the Base64Pipe stream is necessary to complete the encoding (but does not close ostream).
Given a write-like function writefunc, which takes an I/O stream as its first argument, base64(writefunc, args...) calls writefunc to write args... to a base64-encoded string, and returns the string. base64(args...) is equivalent to base64(write, args...): it converts its arguments into bytes using the standard write functions and returns the base64-encoded string.
Just as text output is performed by print and user-defined types can indicate their textual representation by overloading show, Julia provides a standardized mechanism for rich multimedia output (such as images, formatted text, or even audio and video), consisting of three parts:
The base Julia runtime provides only plain-text display, but richer displays may be enabled by loading external modules or by using graphical Julia environments (such as the IPython-based IJulia notebook).
Display x using the topmost applicable display in the display stack, typically using the richest supported multimedia output for x, with plain-text STDOUT output as a fallback. The display(d, x) variant attempts to display x on the given display d only, throwing a MethodError if d cannot display objects of this type.
There are also two variants with a mime argument (a MIME type string, such as "image/png"), which attempt to display x using the requesed MIME type only, throwing a MethodError if this type is not supported by either the display(s) or by x. With these variants, one can also supply the “raw” data in the requested MIME type by passing x::String (for MIME types with text-based storage, such as text/html or application/postscript) or x::Vector{Uint8} (for binary MIME types).
By default, the redisplay functions simply call display. However, some display backends may override redisplay to modify an existing display of x (if any). Using redisplay is also a hint to the backend that x may be redisplayed several times, and the backend may choose to defer the display until (for example) the next interactive prompt.
Returns a boolean value indicating whether the given mime type (string) is displayable by any of the displays in the current display stack, or specifically by the display d in the second variant.
The display functions ultimately call writemime in order to write an object x as a given mime type to a given I/O stream (usually a memory buffer), if possible. In order to provide a rich multimedia representation of a user-defined type T, it is only necessary to define a new writemime method for T, via: writemime(stream, ::MIME"mime", x::T) = ..., where mime is a MIME-type string and the function body calls write (or similar) to write that representation of x to stream. (Note that the MIME"" notation only supports literal strings; to construct MIME types in a more flexible manner use MIME{symbol("")}.)
For example, if you define a MyImage type and know how to write it to a PNG file, you could define a function writemime(stream, ::MIME"image/png", x::MyImage) = ...` to allow your images to be displayed on any PNG-capable Display (such as IJulia). As usual, be sure to import Base.writemime in order to add new methods to the built-in Julia function writemime.
Technically, the MIME"mime" macro defines a singleton type for the given mime string, which allows us to exploit Julia’s dispatch mechanisms in determining how to display objects of any given type.
Returns a boolean value indicating whether or not the object x can be written as the given mime type. (By default, this is determined automatically by the existence of the corresponding writemime function for typeof(x).)
Returns a String or Vector{Uint8} containing the representation of x in the requested mime type, as written by writemime (throwing a MethodError if no appropriate writemime is available). A String is returned for MIME types with textual representations (such as "text/html" or "application/postscript"), whereas binary data is returned as Vector{Uint8}. (The function istext(mime) returns whether or not Julia treats a given mime type as text.)
As a special case, if x is a String (for textual MIME types) or a Vector{Uint8} (for binary MIME types), the reprmime function assumes that x is already in the requested mime format and simply returns x.
Returns a String containing the representation of x in the requested mime type. This is similar to reprmime except that binary data is base64-encoded as an ASCII string.
As mentioned above, one can also define new display backends. For example, a module that can display PNG images in a window can register this capability with Julia, so that calling display(x) on types with PNG representations will automatically display the image using the module’s window.
In order to define a new display backend, one should first create a subtype D of the abstract class Display. Then, for each MIME type (mime string) that can be displayed on D, one should define a function display(d::D, ::MIME"mime", x) = ... that displays x as that MIME type, usually by calling reprmime(mime, x). A MethodError should be thrown if x cannot be displayed as that MIME type; this is automatic if one calls reprmime. Finally, one should define a function display(d::D, x) that queries mimewritable(mime, x) for the mime types supported by D and displays the “best” one; a MethodError should be thrown if no supported MIME types are found for x. Similarly, some subtypes may wish to override redisplay(d::D, ...). (Again, one should import Base.display to add new methods to display.) The return values of these functions are up to the implementation (since in some cases it may be useful to return a display “handle” of some type). The display functions for D can then be called directly, but they can also be invoked automatically from display(x) simply by pushing a new display onto the display-backend stack with:
Pushes a new display d on top of the global display-backend stack. Calling display(x) or display(mime, x) will display x on the topmost compatible backend in the stack (i.e., the topmost backend that does not throw a MethodError).
Pop the topmost backend off of the display-backend stack, or the topmost copy of d in the second variant.
Returns a TextDisplay <: Display, which can display any object as the text/plain MIME type (only), writing the text representation to the given I/O stream. (The text representation is the same as the way an object is printed in the Julia REPL.)
Determine whether a MIME type is text data.
Create an Array whose values are linked to a file, using memory-mapping. This provides a convenient way of working with data too large to fit in the computer’s memory.
The type determines how the bytes of the array are interpreted. Note that the file must be stored in binary format, and no format conversions are possible (this is a limitation of operating systems, not Julia).
dims is a tuple specifying the size of the array.
The file is passed via the stream argument. When you initialize the stream, use "r" for a “read-only” array, and "w+" to create a new array used to write values to disk.
Optionally, you can specify an offset (in bytes) if, for example, you want to skip over a header in the file. The default value for the offset is the current stream position.
Example:
# Create a file for mmapping
# (you could alternatively use mmap_array to do this step, too)
A = rand(1:20, 5, 30)
s = open("/tmp/mmap.bin", "w+")
# We'll write the dimensions of the array as the first two Ints in the file
write(s, size(A,1))
write(s, size(A,2))
# Now write the data
write(s, A)
close(s)
# Test by reading it back in
s = open("/tmp/mmap.bin") # default is read-only
m = read(s, Int)
n = read(s, Int)
A2 = mmap_array(Int, (m,n), s)
This would create a m-by-n Matrix{Int}, linked to the file associated with stream s.
A more portable file would need to encode the word size—32 bit or 64 bit—and endianness information in the header. In practice, consider encoding binary data using standard formats like HDF5 (which can be used with memory-mapping).
Create a BitArray whose values are linked to a file, using memory-mapping; it has the same purpose, works in the same way, and has the same arguments, as mmap_array(), but the byte representation is different. The type parameter is optional, and must be Bool if given.
Example: B = mmap_bitarray((25,30000), s)
This would create a 25-by-30000 BitArray, linked to the file associated with stream s.
Forces synchronization between the in-memory version of a memory-mapped Array or BitArray and the on-disk version.
Forces synchronization of the mmap’d memory region from ptr to ptr+len. Flags defaults to MS_SYNC, but can be a combination of MS_ASYNC, MS_SYNC, or MS_INVALIDATE. See your platform man page for specifics. The flags argument is not valid on Windows.
You may not need to call msync, because synchronization is performed at intervals automatically by the operating system. However, you can call this directly if, for example, you are concerned about losing the result of a long-running calculation.
Enum constant for msync. See your platform man page for details. (not available on Windows).
Enum constant for msync. See your platform man page for details. (not available on Windows).
Enum constant for msync. See your platform man page for details. (not available on Windows).
Low-level interface to the mmap system call. See the man page.
Low-level interface for unmapping memory (see the man page). With mmap_array you do not need to call this directly; the memory is unmapped for you when the array goes out of scope.
Bool Int8 Uint8 Int16 Uint16 Int32 Uint32 Int64 Uint64 Int128 Uint128 Float16 Float32 Float64 Complex64 Complex128
Unary minus operator.
Binary addition operator.
Binary subtraction operator.
Binary multiplication operator.
Binary left-division operator.
Binary right-division operator.
Binary exponentiation operator.
Element-wise binary addition operator.
Element-wise binary subtraction operator.
Element-wise binary multiplication operator.
Element-wise binary left division operator.
Element-wise binary right division operator.
Element-wise binary exponentiation operator.
Compute a/b, truncating to an integer
Largest integer less than or equal to a/b
Modulus after division, returning in the range [0,m)
Remainder after division
Compute x/y and x%y at the same time
Remainder after division. The operator form of rem.
Modulus after division, returning in the range (0,m]
Remainder after division, returning in the range (0,m]
Rational division
Approximate the number x as a rational fraction
Numerator of the rational representation of x
Denominator of the rational representation of x
Left shift operator.
Right shift operator.
Unsigned right shift operator.
Range operator. a:b constructs a range from a to b with a step size of 1, and a:s:b is similar but uses a step size of s. These syntaxes call the function colon. The colon is also used in indexing to select whole dimensions.
Called by : syntax for constructing ranges.
Numeric equality operator. Compares numbers and number-like values (e.g. arrays) by numeric value. True for numbers of different types that represent the same value (e.g. 2 and 2.0). Follows IEEE semantics for floating-point numbers. New numeric types should implement this function for two arguments of the new type.
Not-equals comparison operator. Always gives the opposite answer as ==. New types should generally not implement this, and rely on the fallback definition !=(x,y) = !(x==y) instead.
Equivalent to !is(x, y)
Less-than comparison operator. New numeric types should implement this function for two arguments of the new type.
Less-than-or-equals comparison operator.
Greater-than comparison operator. Generally, new types should implement < instead of this function, and rely on the fallback definition >(x,y) = y<x.
Greater-than-or-equals comparison operator.
Element-wise equality comparison operator.
Element-wise not-equals comparison operator.
Element-wise less-than comparison operator.
Element-wise less-than-or-equals comparison operator.
Element-wise greater-than comparison operator.
Element-wise greater-than-or-equals comparison operator.
Return -1, 0, or 1 depending on whether x<y, x==y, or x>y, respectively.
Bitwise not
Bitwise and
Bitwise or
Bitwise exclusive or
Boolean not
Boolean and
Boolean or
Matrix operator A \ B^{H}
Matrix operator A \ B^{T}
Matrix operator A B
Matrix operator A B^{H}
Matrix operator A B^{T}
Matrix operator A / B^{H}
Matrix operator A / B^{T}
Matrix operator A^{H} \ B
Matrix operator A^{H} \ B^{H}
Matrix operator A^{H} B
Matrix operator A^{H} B^{H}
Matrix operator A^{H} / B
Matrix operator A^{H} / B^{H}
Matrix operator A^{T} \ B
Matrix operator A^{T} \ B^{T}
Matrix operator A^{T} B
Matrix operator A^{T} B^{T}
Matrix operator A^{T} / B
Matrix operator A^{T} / B^{T}
Inexact equality comparison - behaves slightly different depending on types of input args:
For default tolerance arguments, maxeps = max(eps(abs(x)), eps(abs(y))).
Compute sine of x, where x is in radians
Compute cosine of x, where x is in radians
Compute tangent of x, where x is in radians
Compute sine of x, where x is in degrees
Compute cosine of x, where x is in degrees
Compute tangent of x, where x is in degrees
Compute \(\sin(\pi x)\) more accurately than sin(pi*x), especially for large x.
Compute \(\cos(\pi x)\) more accurately than cos(pi*x), especially for large x.
Compute hyperbolic sine of x
Compute hyperbolic cosine of x
Compute hyperbolic tangent of x
Compute the inverse sine of x, where the output is in radians
Compute the inverse cosine of x, where the output is in radians
Compute the inverse tangent of x, where the output is in radians
Compute the inverse tangent of y/x, using the signs of both x and y to determine the quadrant of the return value.
Compute the inverse sine of x, where the output is in degrees
Compute the inverse cosine of x, where the output is in degrees
Compute the inverse tangent of x, where the output is in degrees
Compute the secant of x, where x is in radians
Compute the cosecant of x, where x is in radians
Compute the cotangent of x, where x is in radians
Compute the secant of x, where x is in degrees
Compute the cosecant of x, where x is in degrees
Compute the cotangent of x, where x is in degrees
Compute the inverse secant of x, where the output is in radians
Compute the inverse cosecant of x, where the output is in radians
Compute the inverse cotangent of x, where the output is in radians
Compute the inverse secant of x, where the output is in degrees
Compute the inverse cosecant of x, where the output is in degrees
Compute the inverse cotangent of x, where the output is in degrees
Compute the hyperbolic secant of x
Compute the hyperbolic cosecant of x
Compute the hyperbolic cotangent of x
Compute the inverse hyperbolic sine of x
Compute the inverse hyperbolic cosine of x
Compute the inverse hyperbolic tangent of x
Compute the inverse hyperbolic secant of x
Compute the inverse hyperbolic cosecant of x
Compute the inverse hyperbolic cotangent of x
Compute \(\sin(\pi x) / (\pi x)\) if \(x \neq 0\), and \(1\) if \(x = 0\).
Compute \(\cos(\pi x) / x - \sin(\pi x) / (\pi x^2)\) if \(x \neq 0\), and \(0\) if \(x = 0\). This is the derivative of sinc(x).
Convert x from degrees to radians
Convert x from radians to degrees
Compute the \(\sqrt{x^2+y^2}\) avoiding overflow and underflow
Compute the natural logarithm of x. Throws DomainError for negative Real arguments. Use complex negative arguments instead.
Compute the logarithm of x to base 2. Throws DomainError for negative Real arguments.
Compute the logarithm of x to base 10. Throws DomainError for negative Real arguments.
Accurate natural logarithm of 1+x. Throws DomainError for Real arguments less than -1.
Return a number x such that it has a magnitude in the interval [1/2, 1) or 0, and val = \(x \times 2^{exp}\).
Compute \(e^x\)
Compute \(2^x\)
Compute \(10^x\)
Compute \(x \times 2^n\)
Return a tuple (fpart,ipart) of the fractional and integral parts of a number. Both parts have the same sign as the argument.
Accurately compute \(e^x-1\)
round(x) returns the nearest integral value of the same type as x to x. round(x, digits) rounds to the specified number of digits after the decimal place, or before if negative, e.g., round(pi,2) is 3.14. round(x, digits, base) rounds using a different base, defaulting to 10, e.g., round(pi, 3, 2) is 3.125.
Returns the nearest integral value of the same type as x not less than x. digits and base work as above.
Returns the nearest integral value of the same type as x not greater than x. digits and base work as above.
Returns the nearest integral value of the same type as x not greater in magnitude than x. digits and base work as above.
Returns the nearest integer to x.
Returns the nearest integer not less than x.
Returns the nearest integer not greater than x.
Returns the nearest integer not greater in magnitude than x.
Rounds (in the sense of round) x so that there are digits significant digits, under a base base representation, default 10. E.g., signif(123.456, 2) is 120.0, and signif(357.913, 4, 2) is 352.0.
Return the minimum of the arguments. Operates elementwise over arrays.
Return the maximum of the arguments. Operates elementwise over arrays.
Return x if lo <= x <= hi. If x < lo, return lo. If x > hi, return hi.
Absolute value of x
Squared absolute value of x
Return x such that it has the same sign as y
Return +1 if x is positive, 0 if x == 0, and -1 if x is negative.
Returns 1 if the value of the sign of x is negative, otherwise 0.
Return x with its sign flipped if y is negative. For example abs(x) = flipsign(x,x).
Return \(\sqrt{x}\). Throws DomainError for negative Real arguments. Use complex negative arguments instead.
Integer square root.
Return \(x^{1/3}\)
Compute the error function of x, defined by \(\frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt\) for arbitrary complex x.
Compute the complementary error function of x, defined by \(1 - \operatorname{erf}(x)\).
Compute the scaled complementary error function of x, defined by \(e^{x^2} \operatorname{erfc}(x)\). Note also that \(\operatorname{erfcx}(-ix)\) computes the Faddeeva function \(w(x)\).
Compute the imaginary error function of x, defined by \(-i \operatorname{erf}(ix)\).
Compute the Dawson function (scaled imaginary error function) of x, defined by \(\frac{\sqrt{\pi}}{2} e^{-x^2} \operatorname{erfi}(x)\).
Compute the inverse error function of a real x, defined by \(\operatorname{erf}(\operatorname{erfinv}(x)) = x\).
Compute the inverse error complementary function of a real x, defined by \(\operatorname{erfc}(\operatorname{erfcinv}(x)) = x\).
Return the real part of the complex number z
Return the imaginary part of the complex number z
Return both the real and imaginary parts of the complex number z
Compute the complex conjugate of a complex number z
Compute the phase angle of a complex number z
Return cos(z) + i*sin(z) if z is real. Return (cos(real(z)) + i*sin(real(z)))/exp(imag(z)) if z is complex
Number of ways to choose k out of n items
Factorial of n
Compute factorial(n)/factorial(k)
Compute the prime factorization of an integer n. Returns a dictionary. The keys of the dictionary correspond to the factors, and hence are of the same type as n. The value associated with each key indicates the number of times the factor appears in the factorization.
Example: \(100=2*2*5*5\); then, factor(100) -> [5=>2,2=>2]
Greatest common (positive) divisor (or zero if x and y are both zero).
Least common (non-negative) multiple.
Greatest common (positive) divisor, also returning integer coefficients u and v that solve ux+vy == gcd(x,y)
Test whether n is a power of two
Next power of two not less than n
Previous power of two not greater than n
Next power of a not less than n
Previous power of a not greater than n
Next integer not less than n that can be written as \(\prod k_i^{p_i}\) for integers \(p_1\), \(p_2\), etc.
Previous integer not greater than n that can be written as \(\prod k_i^{p_i}\) for integers \(p_1\), \(p_2\), etc.
Take the inverse of x modulo m: y such that \(xy = 1 \pmod m\)
Compute \(x^p \pmod m\)
Compute the gamma function of x
Compute the logarithm of absolute value of gamma(x)
Compute the logarithmic factorial of x
Compute the digamma function of x (the logarithmic derivative of gamma(x))
Compute the inverse digamma function of x.
Compute the trigamma function of x (the logarithmic second derivative of gamma(x))
Compute the polygamma function of order m of argument x (the (m+1)th derivative of the logarithm of gamma(x))
kth derivative of the Airy function \(\operatorname{Ai}(x)\).
Airy function \(\operatorname{Ai}(x)\).
Airy function derivative \(\operatorname{Ai}'(x)\).
Airy function derivative \(\operatorname{Ai}'(x)\).
Airy function \(\operatorname{Bi}(x)\).
Airy function derivative \(\operatorname{Bi}'(x)\).
Bessel function of the first kind of order 0, \(J_0(x)\).
Bessel function of the first kind of order 1, \(J_1(x)\).
Bessel function of the first kind of order nu, \(J_\nu(x)\).
Bessel function of the second kind of order 0, \(Y_0(x)\).
Bessel function of the second kind of order 1, \(Y_1(x)\).
Bessel function of the second kind of order nu, \(Y_\nu(x)\).
Bessel function of the third kind of order nu, \(H^{(1)}_\nu(x)\).
Bessel function of the third kind of order nu, \(H^{(2)}_\nu(x)\).
Bessel function of the third kind of order nu (Hankel function). k is either 1 or 2, selecting hankelh1 or hankelh2, respectively.
Modified Bessel function of the first kind of order nu, \(I_\nu(x)\).
Modified Bessel function of the second kind of order nu, \(K_\nu(x)\).
Euler integral of the first kind \(\operatorname{B}(x,y) = \Gamma(x)\Gamma(y)/\Gamma(x+y)\).
Natural logarithm of the absolute value of the beta function \(\log(|\operatorname{B}(x,y)|)\).
Dirichlet eta function \(\eta(s) = \sum^\infty_{n=1}(-)^{n-1}/n^{s}\).
Riemann zeta function \(\zeta(s)\).
Hash two integers into a single integer. Useful for constructing hash functions.
Compute the number of digits in number n written in base b.
Convert an integer to a binary string, optionally specifying a number of digits to pad to.
Convert an integer to a hexadecimal string, optionally specifying a number of digits to pad to.
Convert an integer to a decimal string, optionally specifying a number of digits to pad to.
Convert an integer to an octal string, optionally specifying a number of digits to pad to.
Convert an integer to a string in the given base, optionally specifying a number of digits to pad to. The base can be specified as either an integer, or as a Uint8 array of character values to use as digit symbols.
Returns an array of the digits of n in the given base, optionally padded with zeros to a specified size. More significant digits are at higher indexes, such that n == sum([digits[k]*base^(k-1) for k=1:length(digits)]).
A string giving the literal bit representation of a number.
Parse a string as an integer in the given base (default 10), yielding a number of the specified type (default Int).
Parse a string as a decimal floating point number, yielding a number of the specified type.
Convert a number to a maximum precision representation (typically BigInt or BigFloat). See BigFloat for information about some pitfalls with floating-point numbers.
Convert a number or numeric array to boolean
Convert a number or array to the default integer type on your platform. Alternatively, x can be a string, which is parsed as an integer.
Convert a number or array to the default unsigned integer type on your platform. Alternatively, x can be a string, which is parsed as an unsigned integer.
Convert a number or array to integer type. If x is already of integer type it is unchanged, otherwise it converts it to the default integer type on your platform.
Convert a number to a signed integer
Convert a number to an unsigned integer
Convert a number or array to Int8 data type
Convert a number or array to Int16 data type
Convert a number or array to Int32 data type
Convert a number or array to Int64 data type
Convert a number or array to Int128 data type
Convert a number or array to Uint8 data type
Convert a number or array to Uint16 data type
Convert a number or array to Uint32 data type
Convert a number or array to Uint64 data type
Convert a number or array to Uint128 data type
Convert a number or array to Float16 data type
Convert a number or array to Float32 data type
Convert a number or array to Float64 data type
Convert a number or array to Float32 data type, returning true if successful. The result of the conversion is stored in out[1].
Convert a number or array to Float64 data type, returning true if successful. The result of the conversion is stored in out[1].
Convert a number, array, or string to a FloatingPoint data type. For numeric data, the smallest suitable FloatingPoint type is used. For strings, it converts to Float64.
Extract the significand(s) (a.k.a. mantissa), in binary representation, of a floating-point number or array.
For example, significand(15.2)/15.2 == 0.125, and significand(15.2)*8 == 15.2
Get the exponent of a normalized floating-point number.
Convert to r+i*im represented as a Complex64 data type
Convert to r+i*im represented as a Complex128 data type
Convert a number or array to Char data type
Convert real numbers or arrays to complex
Byte-swap an integer
Get a hexadecimal string of the binary representation of a floating point number
Convert a hexadecimal string to the floating point number it represents
Convert an arbitrarily long hexadecimal string to its binary representation. Returns an Array{Uint8, 1}, i.e. an array of bytes.
Convert an array of bytes to its hexadecimal representation. All characters are in lower-case. Returns an ASCIIString.
Get the multiplicative identity element for the type of x (x can also specify the type itself). For matrices, returns an identity matrix of the appropriate size and type.
Get the additive identity element for the type of x (x can also specify the type itself).
The constant pi
The imaginary unit
The constant e
Catalan’s constant
Positive infinity of type Float64
Positive infinity of type Float32
Positive infinity of type Float16
A not-a-number value of type Float64
A not-a-number value of type Float32
A not-a-number value of type Float16
Test whether a floating point number is subnormal
Test whether a number is finite
Test whether a number is infinite
Test whether a floating point number is not a number (NaN)
Returns infinity in the same floating point type as f (or f can by the type itself)
Returns NaN in the same floating point type as f (or f can by the type itself)
Get the next floating point number in lexicographic order
Get the previous floating point number in lexicographic order
Test whether x or all its elements are numerically equal to some integer
Test whether x or all its elements are numerically equal to some real number
Create an arbitrary precision integer. x may be an Int (or anything that can be converted to an Int) or a String. The usual mathematical operators are defined for this type, and results are promoted to a BigInt.
Create an arbitrary precision floating point number. x may be an Integer, a Float64, a String or a BigInt. The usual mathematical operators are defined for this type, and results are promoted to a BigFloat. Note that because floating-point numbers are not exactly-representable in decimal notation, BigFloat(2.1) may not yield what you expect. You may prefer to initialize constants using strings, e.g., BigFloat("2.1").
Get the current floating point rounding mode. Valid modes are RoundNearest, RoundToZero, RoundUp and RoundDown.
Set the floating point rounding mode. See get_rounding for available modes
Change the floating point rounding mode for the duration of f. It is logically equivalent to:
old = get_rounding()
set_rounding(mode)
f()
set_rounding(old)
See get_rounding for available rounding modes.
Number of ones in the binary representation of x.
Example: count_ones(7) -> 3
Number of zeros in the binary representation of x.
Example: count_zeros(int32(2 ^ 16 - 1)) -> 16
Number of zeros leading the binary representation of x.
Example: leading_zeros(int32(1)) -> 31
Number of ones leading the binary representation of x.
Example: leading_ones(int32(2 ^ 32 - 2)) -> 31
Number of zeros trailing the binary representation of x.
Example: trailing_zeros(2) -> 1
Number of ones trailing the binary representation of x.
Example: trailing_ones(3) -> 2
Returns true if x is prime, and false otherwise.
Example: isprime(3) -> true
Returns a collection of the prime numbers <= n.
Returns true if x is odd (that is, not divisible by 2), and false otherwise.
Example: isodd(9) -> false
Returns true is x is even (that is, divisible by 2), and false otherwise.
Example: iseven(1) -> false
The BigFloat type implements arbitrary-precision floating-point aritmetic using the GNU MPFR library.
Get the precision of a floating point number, as defined by the effective number of bits in the mantissa.
Get the precision (in bits) currently used for BigFloat arithmetic.
Set the precision (in bits) to be used to BigFloat arithmetic.
Change the BigFloat arithmetic precision (in bits) for the duration of f. It is logically equivalent to:
old = get_bigfloat_precision()
set_bigfloat_precision(precision)
f()
set_bigfloat_precision(old)
Get the current BigFloat rounding mode. Valid modes are RoundNearest, RoundToZero, RoundUp, RoundDown, RoundFromZero
Set the BigFloat rounding mode. See get_bigfloat_rounding for available modes
Change the BigFloat rounding mode for the duration of f. See get_bigfloat_rounding for available rounding modes; see also with_bigfloat_precision.
Random number generateion in Julia uses the Mersenne Twister library. Julia has a global RNG, which is used by default. Multiple RNGs can be plugged in using the AbstractRNG object, which can then be used to have multiple streams of random numbers. Currently, only MersenneTwister is supported.
Seed the RNG with a seed, which may be an unsigned integer or a vector of unsigned integers. seed can even be a filename, in which case the seed is read from a file. If the argument rng is not provided, the default global RNG is seeded.
Create a MersenneTwister RNG object. Different RNG objects can have their own seeds, which may be useful for generating different streams of random numbers.
Generate a Float64 random number uniformly in [0,1)
Populate the array A with random number generated from the specified RNG.
Generate a random Float64 number or array of the size specified by dims, using the specified RNG object. Currently, MersenneTwister is the only available Random Number Generator (RNG), which may be seeded using srand.
Generate a random Float64 array of the size specified by dims
Generate a random integer of the given type. Optionally, generate an array of random integers of the given type by specifying dims.
Generate a random integer from the inclusive interval specified by Range1 r (for example, 1:n). Optionally, generate a random integer array.
Generate a random boolean value. Optionally, generate an array of random boolean values.
Fill an array with random boolean values. A may be an Array or a BitArray.
Generate a normally-distributed random number with mean 0 and standard deviation 1. Optionally generate an array of normally-distributed random numbers.
Fill the array A with normally-distributed (mean 0, standard deviation 1) random numbers. Also see the rand function.
Generate a nxn symmetric array of normally-distributed random numbers with mean 0 and standard deviation 1.
Returns the number of dimensions of A
Returns a tuple containing the dimensions of A
Tests whether A or its elements are of type T
Returns the number of elements in A
Counts the number of nonzero values in array A (dense or sparse)
Convert an array to its complex conjugate in-place
Returns the distance in memory (in number of elements) between adjacent elements in dimension k
Returns a tuple of the memory strides in each dimension
Returns a tuple of subscripts into an array with dimensions dims, corresponding to the linear index index
Example i, j, ... = ind2sub(size(A), indmax(A)) provides the indices of the maximum element
The inverse of ind2sub, returns the linear index corresponding to the provided subscripts
Construct an uninitialized dense array. dims may be a tuple or a series of integer arguments.
Construct a 1-d array of the specified type. This is usually called with the syntax Type[]. Element values can be specified using Type[a,b,c,...].
Construct an uninitialized cell array (heterogeneous array). dims can be either a tuple or a series of integer arguments.
Create an array of all zeros of specified type
Create an array of all ones of specified type
Create an array where every element is infinite and of the specified type
Create an array where every element is NaN of the specified type
Create a BitArray with all values set to true
Create a BitArray with all values set to false
Create an array filled with v
Fill array A with value x
Create an array with the same data as the given array, but with different dimensions. An implementation for a particular type of array may choose whether the data is copied or shared.
Create an uninitialized array of the same type as the given array, but with the specified element type and dimensions. The second and third arguments are both optional. The dims argument may be a tuple or a series of integer arguments.
Change the type-interpretation of a block of memory. For example, reinterpret(Float32, uint32(7)) interprets the 4 bytes corresponding to uint32(7) as a Float32. For arrays, this constructs an array with the same binary data as the given array, but with the specified element type.
n-by-n identity matrix
m-by-n identity matrix
Construct a vector of n linearly-spaced elements from start to stop.
Construct a vector of n logarithmically-spaced numbers from 10^start to 10^stop.
All mathematical operations and functions are supported for arrays
Broadcasts the arrays As to a common size by expanding singleton dimensions, and returns an array of the results f(as...) for each position.
Like broadcast, but store the result of broadcast(f, As...) in the dest array. Note that dest is only used to store the result, and does not supply arguments to f unless it is also listed in the As, as in broadcast!(f, A, A, B) to perform A[:] = broadcast(f, A, B).
Returns a function broadcast_f such that broadcast_function(f)(As...) === broadcast(f, As...). Most useful in the form const broadcast_f = broadcast_function(f).
Like broadcast_function, but for broadcast!.
Returns a subset of array A as specified by inds, where each ind may be an Int, a Range, or a Vector.
Returns a SubArray, which stores the input A and inds rather than computing the result immediately. Calling getindex on a SubArray computes the indices on the fly.
Returns the “parent array” of an array view type (e.g., SubArray), or the array itself if it is not a view
From an array view A, returns the corresponding indexes in the parent
Return all the data of A where the index for dimension d equals i. Equivalent to A[:,:,...,i,:,:,...] where i is in position d.
Create a view of the given indexes of array A, dropping dimensions indexed with scalars.
Store values from array X within some subset of A as specified by inds.
Broadcasts the inds arrays to a common size like broadcast, and returns an array of the results A[ks...], where ks goes over the positions in the broadcast.
Broadcasts the X and inds arrays to a common size and stores the value from each position in X at the indices given by the same positions in inds.
Concatenate the input arrays along the specified dimension
Concatenate along dimension 1
Concatenate along dimension 2
Horizontal and vertical concatenation in one call. This function is called for block matrix syntax. The first argument specifies the number of arguments to concatenate in each block row. For example, [a b;c d e] calls hvcat((2,3),a,b,c,d,e).
If the first argument is a single integer n, then all block rows are assumed to have n block columns.
Reverse A in dimension d.
Equivalent to flipdim(A,1).
Equivalent to flipdim(A,2).
Circularly shift the data in an array. The second argument is a vector giving the amount to shift in each dimension.
Return a vector of the linear indexes of the non-zeros in A.
Return a vector of the linear indexes of A where f returns true.
Return a vector of indexes for each dimension giving the locations of the non-zeros in A.
Return a tuple (I, J, V) where I and J are the row and column indexes of the non-zero values in matrix A, and V is a vector of the non-zero values.
Return a vector of the non-zero values in array A.
Return the index of the first non-zero value in A.
Return the index of the first element equal to v in A.
Return the index of the first element that satisfies the given predicate in A.
Find the next index >= i of a non-zero element of A, or 0 if not found.
Find the next index >= i of an element of A satisfying the given predicate, or 0 if not found.
Find the next index >= i of an element of A equal to v (using ==), or 0 if not found.
Permute the dimensions of array A. perm is a vector specifying a permutation of length ndims(A). This is a generalization of transpose for multi-dimensional arrays. Transpose is equivalent to permute(A,[2,1]).
Like permutedims(), except the inverse of the given permutation is applied.
Remove the dimensions specified by dims from array A
Vectorize an array using column-major convention.
Check two array shapes for compatibility, allowing trailing singleton dimensions, and return whichever shape has more dimensions.
Throw an error if the specified indexes are not in bounds for the given array.
Cumulative product along a dimension.
Cumulative sum along a dimension.
Cumulative sum along a dimension, using the Kahan-Babuska-Neumaier compensated summation algorithm for additional accuracy.
Cumulative minimum along a dimension.
Cumulative maximum along a dimension.
Finite difference operator of matrix or vector.
Compute differences along vector F, using h as the spacing between points. The default spacing is one.
Rotate matrix A 180 degrees.
Rotate matrix A left 90 degrees.
Rotate matrix A right 90 degrees.
Reduce 2-argument function f along dimensions of A. dims is a vector specifying the dimensions to reduce, and initial is the initial value to use in the reductions.
The associativity of the reduction is implementation-dependent; if you need a particular associativity, e.g. left-to-right, you should write your own loop.
Transform the given dimensions of array A using function f. f is called on each slice of A of the form A[...,:,...,:,...]. dims is an integer vector specifying where the colons go in this expression. The results are concatenated along the remaining dimensions. For example, if dims is [1,2] and A is 4-dimensional, f is called on A[:,:,i,j] for all i and j.
Returns the sum of all array elements, using the Kahan-Babuska-Neumaier compensated summation algorithm for additional accuracy.
Given a dims tuple of integers (m, n, ...), call f on all combinations of integers in the ranges 1:m, 1:n, etc. Example:
julia> cartesianmap(println, (2,2))
11
21
12
22
Converts a numeric array to a packed boolean array
Converts a packed boolean array to an array of booleans
Performs a bitwise not operation on B. See ~ operator.
Left rotation operator.
Right rotation operator.
Compute the kth lexicographic permutation of a vector.
Construct a random permutation of the given length.
Return the inverse permutation of v.
Returns true if v is a valid permutation.
Permute vector v in-place, according to permutation p. No checking is done to verify that p is a permutation.
To return a new permutation, use v[p]. Note that this is generally faster than permute!(v,p) for large vectors.
Like permute!, but the inverse of the given permutation is applied.
Construct a random cyclic permutation of the given length.
Return a randomly permuted copy of v.
Return a copy of v reversed from start to stop.
Generate all combinations of n elements from a given iterable object. Because the number of combinations can be very large, this function returns an iterator object. Use collect(combinations(a,n)) to get an array of all combinations.
Generate all permutations of a given iterable object. Because the number of permutations can be very large, this function returns an iterator object. Use collect(permutations(a,n)) to get an array of all permutations.
Generate all integer arrays that sum to n. Because the number of partitions can be very large, this function returns an iterator object. Use collect(partitions(n)) to get an array of all partitions. The number of partitions to generete can be efficiently computed using length(partitions(n)).
Generate all arrays of m integers that sum to n. Because the number of partitions can be very large, this function returns an iterator object. Use collect(partitions(n,m)) to get an array of all partitions. The number of partitions to generete can be efficiently computed using length(partitions(n,m)).
Generate all set partitions of the elements of an array, represented as arrays of arrays. Because the number of partitions can be very large, this function returns an iterator object. Use collect(partitions(array)) to get an array of all partitions. The number of partitions to generete can be efficiently computed using length(partitions(array)).
Compute the mean of whole array v, or optionally along the dimensions in region. Note: Julia does not ignore NaN values in the computation. For applications requiring the handling of missing data, the DataArray package is recommended.
Compute the sample standard deviation of a vector or array v, optionally along dimensions in region. The algorithm returns an estimator of the generative distribution’s standard deviation under the assumption that each entry of v is an IID drawn from that generative distribution. This computation is equivalent to calculating sqrt(sum((v - mean(v)).^2) / (length(v) - 1)). Note: Julia does not ignore NaN values in the computation. For applications requiring the handling of missing data, the DataArray package is recommended.
Compute the sample standard deviation of a vector v with known mean m. Note: Julia does not ignore NaN values in the computation.
Compute the sample variance of a vector or array v, optionally along dimensions in region. The algorithm will return an estimator of the generative distribution’s variance under the assumption that each entry of v is an IID drawn from that generative distribution. This computation is equivalent to calculating sum((v - mean(v)).^2) / (length(v) - 1). Note: Julia does not ignore NaN values in the computation. For applications requiring the handling of missing data, the DataArray package is recommended.
Compute the sample variance of a vector v with known mean m. Note: Julia does not ignore NaN values in the computation.
Compute the median of a vector v. If keyword argument checknan is true (the default), an error is raised for data containing NaN values. Note: Julia does not ignore NaN values in the computation. For applications requiring the handling of missing data, the DataArray package is recommended.
Like median, but may overwrite the input vector.
Compute the histogram of v, optionally using approximately n bins. The return values are a range e, which correspond to the edges of the bins, and counts containing the number of elements of v in each bin. Note: Julia does not ignore NaN values in the computation.
Compute the histogram of v using a vector/range e as the edges for the bins. The result will be a vector of length length(e) - 1, such that the element at location i satisfies sum(e[i] .< v .<= e[i+1]). Note: Julia does not ignore NaN values in the computation.
Compute a “2d histogram” of a set of N points specified by N-by-2 matrix M. Arguments e1 and e2 are bins for each dimension, specified either as integer bin counts or vectors of bin edges. The result is a tuple of edge1 (the bin edges used in the first dimension), edge2 (the bin edges used in the second dimension), and counts, a histogram matrix of size (length(edge1)-1, length(edge2)-1). Note: Julia does not ignore NaN values in the computation.
Compute nice bin ranges for the edges of a histogram of v, using approximately n bins. The resulting step sizes will be 1, 2 or 5 multiplied by a power of 10. Note: Julia does not ignore NaN values in the computation.
Compute the midpoints of the bins with edges e. The result is a vector/range of length length(e) - 1. Note: Julia does not ignore NaN values in the computation.
Compute the quantiles of a vector v at a specified set of probability values p. Note: Julia does not ignore NaN values in the computation.
Compute the quantile of a vector v at the probability p. Note: Julia does not ignore NaN values in the computation.
Like quantile, but overwrites the input vector.
Compute the Pearson covariance between two vectors v1 and v2. If called with a single element v, then computes covariance of columns of v. Note: Julia does not ignore NaN values in the computation.
Compute the Pearson correlation between two vectors v1 and v2. If called with a single element v, then computes correlation of columns of v. Note: Julia does not ignore NaN values in the computation.
FFT functions in Julia are largely implemented by calling functions from FFTW
Performs a multidimensional FFT of the array A. The optional dims argument specifies an iterable subset of dimensions (e.g. an integer, range, tuple, or array) to transform along. Most efficient if the size of A along the transformed dimensions is a product of small primes; see nextprod(). See also plan_fft() for even greater efficiency.
A one-dimensional FFT computes the one-dimensional discrete Fourier transform (DFT) as defined by \(\operatorname{DFT}[k] = \sum_{n=1}^{\operatorname{length}(A)} \exp\left(-i\frac{2\pi (n-1)(k-1)}{\operatorname{length}(A)} \right) A[n]\). A multidimensional FFT simply performs this operation along each transformed dimension of A.
Same as fft(), but operates in-place on A, which must be an array of complex floating-point numbers.
Multidimensional inverse FFT.
A one-dimensional backward FFT computes \(\operatorname{BDFT}[k] = \sum_{n=1}^{\operatorname{length}(A)} \exp\left(+i\frac{2\pi (n-1)(k-1)}{\operatorname{length}(A)} \right) A[n]\). A multidimensional backward FFT simply performs this operation along each transformed dimension of A. The inverse FFT computes the same thing divided by the product of the transformed dimensions.
Similar to ifft(), but computes an unnormalized inverse (backward) transform, which must be divided by the product of the sizes of the transformed dimensions in order to obtain the inverse. (This is slightly more efficient than ifft() because it omits a scaling step, which in some applications can be combined with other computational steps elsewhere.)
Pre-plan an optimized FFT along given dimensions (dims) of arrays matching the shape and type of A. (The first two arguments have the same meaning as for fft().) Returns a function plan(A) that computes fft(A, dims) quickly.
The flags argument is a bitwise-or of FFTW planner flags, defaulting to FFTW.ESTIMATE. e.g. passing FFTW.MEASURE or FFTW.PATIENT will instead spend several seconds (or more) benchmarking different possible FFT algorithms and picking the fastest one; see the FFTW manual for more information on planner flags. The optional timelimit argument specifies a rough upper bound on the allowed planning time, in seconds. Passing FFTW.MEASURE or FFTW.PATIENT may cause the input array A to be overwritten with zeros during plan creation.
plan_fft!() is the same as plan_fft() but creates a plan that operates in-place on its argument (which must be an array of complex floating-point numbers). plan_ifft() and so on are similar but produce plans that perform the equivalent of the inverse transforms ifft() and so on.
Same as plan_fft(), but produces a plan that performs inverse transforms ifft().
Same as plan_fft(), but produces a plan that performs an unnormalized backwards transform bfft().
Same as plan_fft(), but operates in-place on A.
Same as plan_ifft(), but operates in-place on A.
Same as plan_bfft(), but operates in-place on A.
Multidimensional FFT of a real array A, exploiting the fact that the transform has conjugate symmetry in order to save roughly half the computational time and storage costs compared with fft(). If A has size (n_1, ..., n_d), the result has size (floor(n_1/2)+1, ..., n_d).
The optional dims argument specifies an iterable subset of one or more dimensions of A to transform, similar to fft(). Instead of (roughly) halving the first dimension of A in the result, the dims[1] dimension is (roughly) halved in the same way.
Inverse of rfft(): for a complex array A, gives the corresponding real array whose FFT yields A in the first half. As for rfft(), dims is an optional subset of dimensions to transform, defaulting to 1:ndims(A).
d is the length of the transformed real array along the dims[1] dimension, which must satisfy d == floor(size(A,dims[1])/2)+1. (This parameter cannot be inferred from size(A) due to the possibility of rounding by the floor function here.)
Similar to irfft() but computes an unnormalized inverse transform (similar to bfft()), which must be divided by the product of the sizes of the transformed dimensions (of the real output array) in order to obtain the inverse transform.
Pre-plan an optimized real-input FFT, similar to plan_fft() except for rfft() instead of fft(). The first two arguments, and the size of the transformed result, are the same as for rfft().
Pre-plan an optimized real-input unnormalized transform, similar to plan_rfft() except for brfft() instead of rfft(). The first two arguments and the size of the transformed result, are the same as for brfft().
Pre-plan an optimized inverse real-input FFT, similar to plan_rfft() except for irfft() and brfft(), respectively. The first three arguments have the same meaning as for irfft().
Performs a multidimensional type-II discrete cosine transform (DCT) of the array A, using the unitary normalization of the DCT. The optional dims argument specifies an iterable subset of dimensions (e.g. an integer, range, tuple, or array) to transform along. Most efficient if the size of A along the transformed dimensions is a product of small primes; see nextprod(). See also plan_dct() for even greater efficiency.
Same as dct!(), except that it operates in-place on A, which must be an array of real or complex floating-point values.
Computes the multidimensional inverse discrete cosine transform (DCT) of the array A (technically, a type-III DCT with the unitary normalization). The optional dims argument specifies an iterable subset of dimensions (e.g. an integer, range, tuple, or array) to transform along. Most efficient if the size of A along the transformed dimensions is a product of small primes; see nextprod(). See also plan_idct() for even greater efficiency.
Pre-plan an optimized discrete cosine transform (DCT), similar to plan_fft() except producing a function that computes dct(). The first two arguments have the same meaning as for dct().
Same as plan_dct(), but operates in-place on A.
Pre-plan an optimized inverse discrete cosine transform (DCT), similar to plan_fft() except producing a function that computes idct(). The first two arguments have the same meaning as for idct().
Same as plan_idct(), but operates in-place on A.
Swap the first and second halves of each dimension of x.
Swap the first and second halves of the given dimension of array x.
Undoes the effect of fftshift.
Apply filter described by vectors a and b to vector x.
Construct vector c such that b = conv(a,c) + r. Equivalent to polynomial division.
Convolution of two vectors. Uses FFT algorithm.
2-D convolution of the matrix A with the 2-D separable kernel generated by the vectors u and v. Uses 2-D FFT algorithm
2-D convolution of the matrix B with the matrix A. Uses 2-D FFT algorithm
Compute the cross-correlation of two vectors.
The following functions are defined within the Base.FFTW module.
Performs a multidimensional real-input/real-output (r2r) transform of type kind of the array A, as defined in the FFTW manual. kind specifies either a discrete cosine transform of various types (FFTW.REDFT00, FFTW.REDFT01, FFTW.REDFT10, or FFTW.REDFT11), a discrete sine transform of various types (FFTW.RODFT00, FFTW.RODFT01, FFTW.RODFT10, or FFTW.RODFT11), a real-input DFT with halfcomplex-format output (FFTW.R2HC and its inverse FFTW.HC2R), or a discrete Hartley transform (FFTW.DHT). The kind argument may be an array or tuple in order to specify different transform types along the different dimensions of A; kind[end] is used for any unspecified dimensions. See the FFTW manual for precise definitions of these transform types, at http://www.fftw.org/doc.
The optional dims argument specifies an iterable subset of dimensions (e.g. an integer, range, tuple, or array) to transform along. kind[i] is then the transform type for dims[i], with kind[end] being used for i > length(kind).
See also plan_r2r() to pre-plan optimized r2r transforms.
Same as r2r(), but operates in-place on A, which must be an array of real or complex floating-point numbers.
Pre-plan an optimized r2r transform, similar to Base.plan_fft() except that the transforms (and the first three arguments) correspond to r2r() and r2r!(), respectively.
Similar to Base.plan_fft(), but corresponds to r2r!().
Although several external packages are available for numeric integration and solution of ordinary differential equations, we also provide some built-in integration support in Julia.
Numerically integrate the function f(x) from a to b, and optionally over additional intervals b to c and so on. Keyword options include a relative error tolerance reltol (defaults to sqrt(eps) in the precision of the endpoints), an absolute error tolerance abstol (defaults to 0), a maximum number of function evaluations maxevals (defaults to 10^7), and the order of the integration rule (defaults to 7).
Returns a pair (I,E) of the estimated integral I and an estimated upper bound on the absolute error E. If maxevals is not exceeded then either E <= abstol or E <= reltol*norm(I) will hold. (Note that it is useful to specify a positive abstol in cases where norm(I) may be zero.)
The endpoints a etcetera can also be complex (in which case the integral is performed over straight-line segments in the complex plane). If the endpoints are BigFloat, then the integration will be performed in BigFloat precision as well (note: it is advisable to increase the integration order in rough proportion to the precision, for smooth integrands). More generally, the precision is set by the precision of the integration endpoints (promoted to floating-point types).
The integrand f(x) can return any numeric scalar, vector, or matrix type, or in fact any type supporting +, -, multiplication by real values, and a norm (i.e., any normed vector space).
The algorithm is an adaptive Gauss-Kronrod integration technique: the integral in each interval is estimated using a Kronrod rule (2*order+1 points) and the error is estimated using an embedded Gauss rule (order points). The interval with the largest error is then subdivided into two intervals and the process is repeated until the desired error tolerance is achieved.
These quadrature rules work best for smooth functions within each interval, so if your function has a known discontinuity or other singularity, it is best to subdivide your interval to put the singularity at an endpoint. For example, if f has a discontinuity at x=0.7 and you want to integrate from 0 to 1, you should use quadgk(f, 0,0.7,1) to subdivide the interval at the point of discontinuity. The integrand is never evaluated exactly at the endpoints of the intervals, so it is possible to integrate functions that diverge at the endpoints as long as the singularity is integrable (for example, a log(x) or 1/sqrt(x) singularity).
For real-valued endpoints, the starting and/or ending points may be infinite. (A coordinate transformation is performed internally to map the infinite interval to a finite one.)
addprocs(4) will add 4 processes on the local machine. This can be used to take advantage of multiple cores.
Keyword argument cman can be used to provide a custom cluster manager to start workers. For example Beowulf clusters are supported via a custom cluster manager implemented in package ClusterManagers.
See the documentation for package ClusterManagers for more information on how to write a custom cluster manager.
Add processes on remote machines via SSH. Requires julia to be installed in the same location on each node, or to be available via a shared file system.
machines is a vector of host definitions of the form [user@]host[:port]. A worker is started for each such definition.
Keyword arguments:
tunnel : if true then SSH tunneling will be used to connect to the worker.
dir : specifies the location of the julia binaries on the worker nodes.
sshflags : specifies additional ssh options, e.g. sshflags=`-i /home/foo/bar.pem` .
Get the number of available processors.
Get the number of available worker processors. This is one less than nprocs(). Equal to nprocs() if nprocs() == 1.
Returns a list of all process identifiers.
Returns a list of all worker process identifiers.
Removes the specified workers.
Interrupt the current executing task on the specified workers. This is equivalent to pressing Ctrl-C on the local machine. If no arguments are given, all workers are interrupted.
Get the id of the current processor.
Transform collections lsts by applying f to each element in parallel. If nprocs() > 1, the calling process will be dedicated to assigning tasks. All other available processes will be used as parallel workers.
If err_retry is true, it retries a failed application of f on a different worker. If err_stop is true, it takes precedence over the value of err_retry and pmap stops execution on the first error.
Call a function asynchronously on the given arguments on the specified processor. Returns a RemoteRef.
Block the current task until some event occurs, depending on the type of the argument:
Wait for and get the value of a remote reference.
Perform wait(remotecall(...)) in one message.
Perform fetch(remotecall(...)) in one message.
Store a value to a remote reference. Implements “shared queue of length 1” semantics: if a value is already present, blocks until the value is removed with take.
Fetch the value of a remote reference, removing it so that the reference is empty again.
Determine whether a RemoteRef has a value stored to it. Note that this function can easily cause race conditions, since by the time you receive its result it may no longer be true. It is recommended that this function only be used on a RemoteRef that is assigned once.
Make an uninitialized remote reference on the local machine.
Make an uninitialized remote reference on processor n.
Waits till testcb returns true or for secs` seconds, whichever is earlier. testcb is polled every pollint seconds.
Execute an expression on an automatically-chosen processor, returning a RemoteRef to the result.
Accepts two arguments, p and an expression, and runs the expression asynchronously on processor p, returning a RemoteRef to the result.
Equivalent to fetch(@spawn expr).
Equivalent to fetch(@spawnat p expr).
Schedule an expression to run on the local machine, also adding it to the set of items that the nearest enclosing @sync waits for.
Wait until all dynamically-enclosed uses of @async, @spawn, and @spawnat complete.
Construct a distributed array. init is a function that accepts a tuple of index ranges. This function should allocate a local chunk of the distributed array and initialize it for the specified indices. dims is the overall size of the distributed array. procs optionally specifies a vector of processor IDs to use. If unspecified, the array is distributed over all worker processes only. Typically, when runnning in distributed mode, i.e., nprocs() > 1, this would mean that no chunk of the distributed array exists on the process hosting the interactive julia prompt. dist is an integer vector specifying how many chunks the distributed array should be divided into in each dimension.
For example, the dfill function that creates a distributed array and fills it with a value v is implemented as:
dfill(v, args...) = DArray(I->fill(v, map(length,I)), args...)
Construct a distributed array of zeros. Trailing arguments are the same as those accepted by darray.
Construct a distributed array of ones. Trailing arguments are the same as those accepted by darray.
Construct a distributed array filled with value x. Trailing arguments are the same as those accepted by darray.
Construct a distributed uniform random array. Trailing arguments are the same as those accepted by darray.
Construct a distributed normal random array. Trailing arguments are the same as those accepted by darray.
Convert a local array to distributed
Get the local piece of a distributed array. Returns an empty array if no local part exists on the calling process.
A tuple describing the indexes owned by the local processor. Returns a tuple with empty ranges if no local part exists on the calling process.
Get the vector of processors storing pieces of d
Run a command object, constructed with backticks. Throws an error if anything goes wrong, including the process exiting with a non-zero status.
Run a command object asynchronously, returning the resulting Process object.
Used in a stream redirect to discard all data written to it. Essentially equivalent to /dev/null on Unix or NUL on Windows. Usage: run(`cat test.txt` |> DevNull)
Run a command object, constructed with backticks, and tell whether it was successful (exited with a code of 0). An exception is raised if the process cannot be started.
Determine whether a process is currently running.
Determine whether a process has exited.
Send a signal to a process. The default is to terminate the process.
Starts running a command asynchronously, and returns a tuple (stream,process). The first value is a stream reading from the process’ standard output.
Starts running a command asynchronously, and returns a tuple (stream,process). The first value is a stream writing to the process’ standard input.
Starts running a command asynchronously, and returns a tuple (stdout,stdin,process) of the output stream and input stream of the process, and the process object itself.
Mark a command object so that running it will not throw an error if the result code is non-zero.
Mark a command object so that it will be run in a new process group, allowing it to outlive the julia process, and not have Ctrl-C interrupts passed to it.
Set environment variables to use when running the given command. env is either a dictionary mapping strings to strings, or an array of strings of the form "var=val".
Redirect operator. Used for piping the output of a process into another (first form) or to redirect the standard output/input of a command to/from a file (second and third forms).
Redirect standard output of a process, appending to the destination file.
Redirect the standard error stream of a process.
Get the local machine’s host name.
Get the IP address of the local machine, as a string of the form “x.x.x.x”.
Get the current working directory.
Set the current working directory. Returns the new current directory.
Temporarily changes the current working directory (HOME if not specified) and applies function f before returning.
Make a new directory with name path and permissions mode. mode defaults to 0o777, modified by the current file creation mask.
Create all directories in the given path, with permissions mode. mode defaults to 0o777, modified by the current file creation mask.
Remove the directory named path.
Get julia’s process ID.
Get the system time in seconds since the epoch, with fairly high (typically, microsecond) resolution. When passed a TmStruct, converts it to a number of seconds since the epoch.
Get the time in nanoseconds. The time corresponding to 0 is undefined, and wraps every 5.8 years.
Convert time, given as a number of seconds since the epoch or a TmStruct, to a formatted string using the given format. Supported formats are the same as those in the standard C library.
Parse a formatted time string into a TmStruct giving the seconds, minute, hour, date, etc. Supported formats are the same as those in the standard C library. On some platforms, timezones will not be parsed correctly. If the result of this function will be passed to time to convert it to seconds since the epoch, the isdst field should be filled in manually. Setting it to -1 will tell the C library to use the current system settings to determine the timezone.
Convert a number of seconds since the epoch to broken-down format, with fields sec, min, hour, mday, month, year, wday, yday, and isdst.
Set a timer to be read by the next call to toc() or toq(). The macro call @time expr can also be used to time evaluation.
A macro to execute and expression, printing time it took to execute and the total number of bytes its execution caused to be allocated, before returning the value of the expression.
A macro to evaluate an expression, discarding the resulting value, instead returning the number of seconds it took to execute as a floating-point number.
A macro to evaluate an expression, discarding the resulting value, instead returning the total number of bytes allocated during evaluation of the expression.
A singleton of this type provides a hash table interface to environment variables.
Reference to the singleton EnvHash, providing a dictionary interface to system environment variables.
Given @unix? a : b, do a on Unix systems (including Linux and OS X) and b elsewhere. See documentation for Handling Platform Variations in the Calling C and Fortran Code section of the manual.
Given @osx? a : b, do a on OS X and b elsewhere. See documentation for Handling Platform Variations in the Calling C and Fortran Code section of the manual.
Given @linux? a : b, do a on Linux and b elsewhere. See documentation for Handling Platform Variations in the Calling C and Fortran Code section of the manual.
Given @windows? a : b, do a on Windows and b elsewhere. See documentation for Handling Platform Variations in the Calling C and Fortran Code section of the manual.
Call function in C-exported shared library, specified by (function name, library) tuple, where each component is a String or :Symbol. Alternatively, ccall may be used to call a function pointer returned by dlsym, but note that this usage is generally discouraged to facilitate future static compilation. Note that the argument type tuple must be a literal tuple, and not a tuple-valued variable or expression.
Obtain a pointer to a global variable in a C-exported shared library, specified exactly as in ccall. Returns a Ptr{Type}, defaulting to Ptr{Void} if no Type argument is supplied. The values can be read or written by unsafe_load or unsafe_store!, respectively.
Generate C-callable function pointer from Julia function. Type annotation of the return value in the callback function is a must for situations where Julia cannot infer the return type automatically.
For example:
function foo()
# body
retval::Float64
end
bar = cfunction(foo, Float64, ())
Load a shared library, returning an opaque handle.
The optional flags argument is a bitwise-or of zero or more of RTLD_LOCAL, RTLD_GLOBAL, RTLD_LAZY, RTLD_NOW, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND, and RTLD_FIRST. These are converted to the corresponding flags of the POSIX (and/or GNU libc and/or MacOS) dlopen command, if possible, or are ignored if the specified functionality is not available on the current platform. The default is RTLD_LAZY|RTLD_DEEPBIND|RTLD_LOCAL. An important usage of these flags, on POSIX platforms, is to specify RTLD_LAZY|RTLD_DEEPBIND|RTLD_GLOBAL in order for the library’s symbols to be available for usage in other shared libraries, in situations where there are dependencies between shared libraries.
Similar to dlopen, except returns a NULL pointer instead of raising errors.
Enum constant for dlopen. See your platform man page for details, if applicable.
Enum constant for dlopen. See your platform man page for details, if applicable.
Enum constant for dlopen. See your platform man page for details, if applicable.
Enum constant for dlopen. See your platform man page for details, if applicable.
Enum constant for dlopen. See your platform man page for details, if applicable.
Enum constant for dlopen. See your platform man page for details, if applicable.
Enum constant for dlopen. See your platform man page for details, if applicable.
Enum constant for dlopen. See your platform man page for details, if applicable.
Look up a symbol from a shared library handle, return callable function pointer on success.
Look up a symbol from a shared library handle, silently return NULL pointer on lookup failure.
Close shared library referenced by handle.
Call malloc from the C standard library.
Call free from the C standard library.
Dereference the pointer p[i] or *p, returning a copy of type T.
Assign to the pointer p[i] = x or *p = x, making a copy of object x into the memory at p.
Copy N elements from a source pointer to a destination, with no checking. The size of an element is determined by the type of the pointers.
Copy N elements from a source array to a destination, starting at offset so in the source and do in the destination.
Copy all elements from collection src to array dest.
Copy N elements from collection src starting at offset so, to array dest starting at offset do.
Get the native address of an array element. Be careful to ensure that a julia reference to a exists as long as this pointer will be used.
Convert an integer to a pointer of the specified element type.
Wrap a native pointer as a Julia Array object. The pointer element type determines the array element type. own optionally specifies whether Julia should take ownership of the memory, calling free on the pointer when the array is no longer referenced.
Get the memory address of a Julia object as a Ptr. The existence of the resulting Ptr will not protect the object from garbage collection, so you must ensure that the object remains referenced for the whole time that the Ptr will be used.
Convert a Ptr to an object reference. Assumes the pointer refers to a valid heap-allocated Julia object. If this is not the case, undefined behavior results, hence this function is considered “unsafe” and should be used with care.
Disable Ctrl-C handler during execution of a function, for calling external code that is not interrupt safe. Intended to be called using do block syntax as follows:
disable_sigint() do
# interrupt-unsafe code
...
end
Re-enable Ctrl-C handler during execution of a function. Temporarily reverses the effect of disable_sigint.
Searches for the first library in names in the paths in the locations list, DL_LOAD_PATH, or system library paths (in that order) which can successfully be dlopen’d. On success, the return value will be one of the names (potentially prefixed by one of the paths in locations). This string can be assigned to a global const and used as the library name in future ccall‘s. On failure, it returns the empty string.
When calling dlopen, the paths in this list will be searched first, in order, before searching the system locations for a valid library handle.
Equivalent to the native char c-type
Equivalent to the native unsigned char c-type (Uint8)
Equivalent to the native signed short c-type (Int16)
Equivalent to the native unsigned short c-type (Uint16)
Equivalent to the native signed int c-type (Int32)
Equivalent to the native unsigned int c-type (Uint32)
Equivalent to the native signed long c-type
Equivalent to the native unsigned long c-type
Equivalent to the native signed long long c-type (Int64)
Equivalent to the native unsigned long long c-type (Uint64)
Equivalent to the native size_t c-type (Uint)
Equivalent to the native ssize_t c-type
Equivalent to the native ptrdiff_t c-type (Int)
Equivalent to the native off_t c-type
Equivalent to the native wchar_t c-type (Int32)
Equivalent to the native float c-type (Float32)
Equivalent to the native double c-type (Float64)
Raise an error with the given message
Throw an object as an exception
Throw an object without changing the current exception backtrace. The default argument is the current exception (if called within a catch block).
Get a backtrace object for the current program point.
Get the backtrace of the current exception, for use within catch blocks.
Get the value of the C library’s errno
Raises a SystemError for errno with the descriptive string sysfunc if bool is true
Convert a system call error code to a descriptive string
Raise an error if cond is false. Also available as the macro @assert expr.
Raise an error if cond is false. Preferred syntax for writings assertions.
The parameters given to a function call are not valid.
An indexing operation into an array tried to access an out-of-bounds element.
No more data was available to read from a file or stream.
Generic error type. The error message, in the .msg field, may provide more specific details.
An indexing operation into an Associative (Dict) or Set like object tried to access or delete a non-existent element.
An error occurred while including, requiring, or using a file. The error specifics should be available in the .error field.
A method with the required type signature does not exist in the given generic function.
The expression passed to the parse function could not be interpreted as a valid Julia expression.
After a client Julia process has exited, further attempts to reference the dead child will throw this exception.
A system call failed with an error code (in the errno global variable).
A type assertion failure, or calling an intrinsic function with an incorrect argument type.
Create a Task (i.e. thread, or coroutine) to execute the given function. The task exits when this function returns.
Switch to the given task. The first time a task is switched to, the task’s function is called with args. On subsequent switches, args are returned from the task’s last call to yieldto.
Get the currently running Task.
Tell whether a task has exited.
Receive the next value passed to produce by the specified task.
Send the given value to the last consume call, switching to the consumer task.
For scheduled tasks, switch back to the scheduler to allow another scheduled task to run. A task that calls this function is still runnable, and will be restarted immediately if there are no other runnable tasks.
Look up the value of a symbol in the current task’s task-local storage.
Assign a value to a symbol in the current task’s task-local storage.
Call the function body with a modified task-local storage, in which value is assigned to symbol; the previous value of symbol, or lack thereof, is restored afterwards. Useful for emulating dynamic scoping.
Create an edge-triggered event source that tasks can wait for. Tasks that call wait on a Condition are suspended and queued. Tasks are woken up when notify is later called on the Condition. Edge triggering means that only tasks waiting at the time notify is called can be woken up. For level-triggered notifications, you must keep extra state to keep track of whether a notification has happened. The RemoteRef type does this, and so can be used for level-triggered events.
Wake up tasks waiting for a condition, passing them val. If all is true (the default), all waiting tasks are woken, otherwise only one is. If error is true, the passed value is raised as an exception in the woken tasks.
Add a task to the scheduler’s queue. This causes the task to run constantly when the system is otherwise idle, unless the task performs a blocking operation such as wait.
Wrap an expression in a Task and add it to the scheduler’s queue.
Wrap an expression in a Task executing it, and return the Task. This only creates a task, and does not run it.
Block the current task for a specified number of seconds.
Create a timer to call the given callback function. The callback is passed two arguments: the timer object itself, and a status code, which will be 0 unless an error occurs. The timer can be started and stopped with start_timer and stop_timer.
Start invoking the callback for a Timer after the specified initial delay, and then repeating with the given interval. Times are in seconds. If repeat is 0, the timer is only triggered once.
Stop invoking the callback for a timer.
Get the name of a module as a symbol.
Get a module’s enclosing module. Main is its own parent.
Get the dynamically current module, which is the module code is currently being read from. In general, this is not the same as the module containing the call to this function.
Get the fully-qualified name of a module as a tuple of symbols. For example, fullname(Base.Pkg) gives (:Base,:Pkg), and fullname(Main) gives ().
Get an array of the names exported by a module, or the fields of a data type.
Determine whether a global is declared const in a given module.
Determine whether a function is generic.
Get the name of a generic function as a symbol, or :anonymous.
Determine the module containing a given definition of a generic function.
Returns a tuple (filename,line) giving the location of a method definition.
Returns an array of the results of functionloc for all matching definitions.
Perform garbage collection. This should not generally be used.
Disable garbage collection. This should be used only with extreme caution, as it can cause memory use to grow without bound.
Re-enable garbage collection after calling gc_disable.
Takes the expression x and returns an equivalent expression with all macros removed (expanded).
Takes the expression x and returns an equivalent expression in lowered form
Returns an array of lowered ASTs for the methods matching the given generic function and type signature.
Returns an array of lowered and type-inferred ASTs for the methods matching the given generic function and type signature.
Prints the LLVM bitcodes generated for running the method matching the given generic function and type signature to STDOUT.
Prints the native assembly instructions generated for running the method matching the given generic function and type signature to STDOUT.
Compile the given function f for the argument tuple (of types) args, but do not execute it.