Questions tagged [data-types]

Mathematica pseudo-types Integer, Real, Rational, Complex, String and Symbol, and their use.

Filter by
Sorted by
Tagged with
2 votes
0 answers

How can I compare two ByteArrays inside FunctionCompile in 13.3

I need a compiled function that takes an array of bytes as input and in the process compares parts of that array. It's really just looking for the occurrence of one array in another. It works if you ...
Kirill Belov's user avatar
4 votes
1 answer

Is it possible to improve efficiency of the function?

I have the following function scriptQ to check whether an expression is a "script" or not. This function is frequently called by others, so I need to ...
Lacia's user avatar
  • 2,208
1 vote
1 answer

How to force Mathematica to return `NumericQ` as True when aplied to some variable in Mathematica?

I want to get a general formula for an expression, so instead of numbers like 5 or Pi I want to insert variables into an expression. But the functions involved check ...
Anixx's user avatar
  • 3,553
0 votes
1 answer

The shortcuts for typing subscript is valid

I installed the Mathematica 13.2 in my new computer, everything worked well excepted that the shortcuts for typing the subscripts "ctrl+ _" doesn't work. I tested that the "ctrl" ...
Knife Lee's user avatar
  • 149
0 votes
0 answers

Mathematica -> OpenCL datatypes

Mathematica -> OpenCL datatypes. I'm trying to work witn OpenCL in Mathematica but having problems matching the datatypes between Mathematica and OpenCL. I've got an OpenCL SHA256 hash funcition (...
kernel density's user avatar
3 votes
1 answer

How to enforce/specify the type of a module local variables similar to the module arguments?

In Mathematica, one can specify the type of a module argument by giving the Head name. I am using type loosely here since Mathematica does not have types. But this does basically the same thing. So ...
Nasser's user avatar
  • 137k
0 votes
0 answers

Defining a differential form in RGTC

I am using RGTC and following one of the tutorials (from RGTC.m - example 4 calculating Killing vectors). I am struggling with fundamental understanding how does the package keeps track of which ...
Vasil Avramov's user avatar
1 vote
0 answers

How use LibraryFunctionDeclaration to call the function with DataStore parameter?

I have a CMakeProject1.dll produced by this code: ...
yode's user avatar
  • 26.3k
2 votes
1 answer

Type Confusion in v13.1.0

Below is an expression that (for me) evaluates differently on the two most recent versions of Mathematica. Can others confirm this? It’s either a bug in v13.1.0, or my installation is faulty (which I ...
James Stein's user avatar
6 votes
1 answer

FunctionCompiling lists of things

I have a compiled function that works on a list of some atomic type e.g. strings, but also want it to work on lists of others (e.g. integers, reals, symbols, etc). Moreover, nothing in the code has to ...
user5601's user avatar
  • 3,581
2 votes
0 answers

When should I use Audio vs Sound Data types?

It seems like mathematica has 2 related data types Audio and sound. Why is there 2 separate data types? When would I use one versus the other? Guesses I know I can convert between them by ...
ions me's user avatar
  • 761
3 votes
1 answer

How do I use a FunctionCompile(d) function in FindMInimum

Suppose I would like to speed up the function in FindMinimum[function[variables],startingPoint] by compiling function I've constructed a minimal working example to describe what I would like to do. ...
Craig Carter's user avatar
  • 3,968
1 vote
0 answers

FunctionCompile Type Errors

This function works uncompiled: Function[{n, m, k}, ParallelSum[ Length[Permutations[i]], {i, IntegerPartitions[m, {n}, Range[0, k]]} ]] but compiling with <...
user avatar
3 votes
1 answer

Type formation rules for 1-position expressions

I made a summary of the rules for formation of types for simple 1-position expressions, as I understand them. Here it is in textual form: A symbol, say, α, is a discrete entity, represented by a ...
user182917's user avatar
12 votes
2 answers

Using DataStructures in FunctionCompile

This is a follow up to this StackExchange question I am trying to do the equivalent of Select on a "FixedArray" data structure. Here is what I have tried so far: ...
Craig Carter's user avatar
  • 3,968
1 vote
0 answers

"Compile-time" patterns

If I define a function like f[x : {_, _Integer}] := (* function body *) then, as I understand it, every time f[expr] is ...
thorimur's user avatar
  • 8,950
3 votes
0 answers

How to use _Complex types in CUDAFunctionLoad?

The documentation for CUDAFunctionLoad specifies various base datatypes you can use for your function's arguments, including ...
Fidel I. Schaposnik's user avatar
1 vote
1 answer

Adding a curve on DensityPlot: Epilog -> First[ContourPlot[...]] why the first?

I would like to understand why I have to add First around ContourPlot in the following example to have it working: ...
StarBucK's user avatar
  • 2,144
2 votes
0 answers

How to use TypeFramework?

I found a paclet "TypeFramework". It seems to be designed for typed programming. How can I use it?
bcegkmqs23's user avatar
3 votes
1 answer

How to use patterns to specify variable type as Boolean (True, False) in analogy to x_Integer, x_Real, x_Complex, x_List, etc

Say I define a function f[x_, y_]:= ..., the concrete definition of which is not important now. What is important though is, that I want ...
Britzel's user avatar
  • 663
1 vote
0 answers

How to restrict the type of input given to the function Input[]?

The function Input[] when evaluated displays a dialog box where one can enter any character. My question is how do I restrict the input only to a certain type such ...
Sâu's user avatar
  • 535
7 votes
1 answer

Provide definition to FunctionCompile

I recently upgraded to Mathematica 12, and I've been excited to explore new features such as FunctionCompile, which produces llvm code. I tried compiling the ...
Alecto Irene Perez's user avatar
1 vote
0 answers

SemanticImport changes "string" type to "quantity" type--how to change during import or after import?

This question may overlap with other questions about the quirks of SemanticImport, but I don't see this specific wrinkle on StackExchange and I hope it will be a simple answer to help me and others ...
KBL's user avatar
  • 623
8 votes
1 answer

What is an example of of idiomatic "typed" WolframScript?

I'd like to make my own "typed function" in WolframScript. Suppose the type we desire is called money, and we'd like to make a function called ...
George's user avatar
  • 3,115
10 votes
2 answers

Make symbols atomic, without losing their type

So, I'd like to define a matrix M, that does not decompose into it's constituents when I do things like Tr[M], but I also want it's type to be retained. (By type, ...
Mahathi Vempati's user avatar
0 votes
0 answers

CompiledFunction::ctfa - Argument should be a rank 4 tensor of machine-size real number

Dear Mathematica community, I got the following error line: CompiledFunction::ctfa "Argument {<<1>>} at position 1 should be a rank 4 tensor of machine-size real number" This ...
Gabriel309's user avatar
0 votes
1 answer

Who knows what happened in this code? (The difference between 3 and 3.)

I have a problem in my code. This code produces two different results when we use GM = {{Sqrt[3.], 0}, {-Sqrt[3], 3}/2} and GM = {{Sqrt[3], 0}, {-Sqrt[3], 3}/2}, where I just use Sqrt[3] instead of ...
finalboss's user avatar
20 votes
1 answer

NumericArray versus PackedArray in MMA12

I just tried to understand the differences between NumericArray and PackedArray in MMA12. The memory footprint of a ...
Michael Weyrauch's user avatar
12 votes
2 answers

Is it possible to restrict the arguments for a function to a specific entity type?

I'm trying to wrap my head around how to work with Mathematica for building (computable) domain specific knowledge. One particular thing I didn't quite understand is how to create symbols for ...
Whil's user avatar
  • 223
26 votes
2 answers

Why no RationalQ or RealQ?

Interesting pattern came up as I go through the homework replies of my students. Why is there no RationalQ or RealQ? We have <...
Andreas Lauschke's user avatar
2 votes
1 answer

Data Type that can contain multiple data types

In MATLAB one can use cell arrays and structures to "hold" data of different types. For example, one can define a cell array in which the first cell contains an array, the second a differently sized ...
Ed Davis's user avatar
13 votes
1 answer

Is it possible to set multiple type to a variable?

Consider this f[x_Real] := 2 x f[1] f[1] f[1.0] 2.0 I want ...
Sumit's user avatar
  • 15.9k
1 vote
2 answers

How to create an unevaluated command like Sequence

I work with linear combinations of graphs, $$c_1 G_1 + c_2 G_2 + \dotsc,$$ and I want to represent them in my Mathematica code. I represent graphs as adjacency matrices, e.g. ...
Deniz's user avatar
  • 215
3 votes
1 answer

How to define "typed" objects and their operator specializations?

I've defined a primitive sort of type system where my objects are defined as lists with an associated identifier: ...
Peeter Joot's user avatar
  • 6,388
1 vote
0 answers

Integer data type mapping problem with SQLInsert in DatabaseLink package

I am working with a following SQL table named "ticket". Now let's see the data types for the columns. ...
PlatoManiac's user avatar
  • 14.6k
4 votes
1 answer

Specify Variable Size

Is there an easy way to specify the variable size and still use them as variables more specifically for the .NETLink? Something like the following I am thinking. ...
William's user avatar
  • 7,565
1 vote
1 answer

Control data type (or precison?) to limit memory usage

I couldn't find the answer to my question, so here it is: I have quite a large table, which I generate in Matlab (for some reasons i use both Matlab and Mathematica, I'd like to use only one of them, ...
vasya's user avatar
  • 11
12 votes
2 answers

How to get the type of an object

I'm looking for a way to get the type of an object: TypeOf["x"] -> String TypeOf[1] -> Integer Or something along those lines.
Burton Samograd's user avatar
5 votes
1 answer

Immutability, Association and typing

I have read the article by Leonid on the question. I am still struggling. I am trying to use Association to inject some pseudo-typing in my code. Here is my ...
Trad Dog's user avatar
  • 450
1 vote
0 answers

Compilation error: "Could not complete external evaluation at..."

I'm pretty new to trying to use Compile[], and I just can't see why I'm getting this error. I have two functions to define beforehand; one of them is a bit odd: <...
Ben Kalziqi's user avatar
  • 1,082
18 votes
0 answers

V10's TypeSystem - what are these function useful for? [closed]

The symbols in the TypeSystem` context are clearly used for working with Datasets, but they seem powerful. I was hoping that someone could help explain how they work and is they are useful for ...
M.R.'s user avatar
  • 31.2k
1 vote
0 answers

Pattern type and list indexing warnings/errors

I'm new to Mathematica and am trying to implement some simple noise functions in it in hopes of eventually finding an integral for them. This is the interesting part of the code: ...
Alemarius Nexus's user avatar
4 votes
2 answers

Type error before replacement rule is applied

When I type a <> "0" /. {a -> "1"} I get the error ...
octopus's user avatar
  • 489
15 votes
1 answer

How to convert a column of a Dataset into a list [closed]

I'm loving the fact that Mathematica has finally implemented the Dataset feature, but I'm still struggling a little with it. I have a Dataset that contains a bunch of functions for different diseases ...
Moppentapper's user avatar
3 votes
1 answer

Datatypes and numbers in Mathematica

I have some questions about numbers in Mathematica: Does Mathematica work with datatypes like int, long, ...
user avatar
4 votes
1 answer

Relative factorisation with scalar quantities

I'd like to find a natural way to tell mathematica that a given unknown in a polynomial should be treated as a number, unlike the other variables. Typically I'd like to sum two polynomials in several ...
picop's user avatar
  • 265
2 votes
1 answer

Type declaration for list arguments

How can I make f[n_Integer]=2*n valid for a list of integers? For example: f[nlist_Integer] := 2*nlist[[1]] does not work ...
anderstood's user avatar
  • 14.2k
1 vote
0 answers

How can I perfect this game for Wolfram Demonstration publication? [closed]

When the messages change the window inactivates, and when I try to host an interactive CDF on my site it turns red and says something about numbers having to be scaled or offset. Any help? I'm ...
Sam's user avatar
  • 39
2 votes
1 answer

Declare type in InputField

Is it possible to declare a type in InputFunction to only accept positive Integers as input? I know i can create an ...
kon's user avatar
  • 263
12 votes
1 answer

Get expression type?

Is there a built in function that distinguishes between different kinds of variables? I mean something like: VariableType[ 123 ] Number ...
Kagaratsch's user avatar
  • 11.9k