Search
 
SCRIPT & CODE EXAMPLE
 

RUST

ndarray rust

// add ndarray = "0.15.4" in cargo.toml file

// Create a three-dimensional f64 array, initialized with zeros
use ndarray::Array3;
let mut temperature = Array3::<f64>::zeros((3, 4, 5));
// or let mut temperature = Array::<f64, 3>::zeros((3, 4, 5));
// Increase the temperature in this location
temperature[[2, 2, 2]] += 0.5;

// Result:
/* temperature = 
	[
    	[
     		[0.0, 0.0, 0.0, 0.0, 0.0],
     		[0.0, 0.0, 0.0, 0.0, 0.0],
     		[0.0, 0.0, 0.0, 0.0, 0.0],
     		[0.0, 0.0, 0.0, 0.0, 0.0]
    	],
		[
     		[0.0, 0.0, 0.0, 0.0, 0.0],
     		[0.0, 0.0, 0.0, 0.0, 0.0],
     		[0.0, 0.0, 0.0, 0.0, 0.0],
     		[0.0, 0.0, 0.0, 0.0, 0.0]
    	],
		[
     		[0.0, 0.0, 0.0, 0.0, 0.0],
     		[0.0, 0.0, 0.0, 0.0, 0.0],
     		[0.0, 0.0, 0.5, 0.0, 0.0],
     		[0.0, 0.0, 0.0, 0.0, 0.0]
    	],
   ]
*/
Comment

PREVIOUS NEXT
Code Example
Rust :: rust lang start a new project 
Rust :: Split text on several separators 
Rust :: armanriazi•rust•vec•some•pop 
Rust :: armanriazi•rust•pattern•design•interior•mutability•refcell 
Rust :: rust•armanriazi•borrowchecker•lifetime 
Rust :: armanriazi•rust•smartpointer•box 
Rust :: check if a string contains consecutive letters that occur only once 
Rust :: rust lang enum 
Rust :: rust enum anonymous struct 
Rust :: armanriazi•rust•thread•recv•try_recv 
Rust :: hwllo world in rust 
Rust :: key value in for loop rust 
Rust :: rust create hashmap from delimited data in string 
Rust :: rust•armanriazi•cast•try_into•unwrap 
Rust :: rust•armanriazi•modified•data•by•compiler•cast•number•i32•to•u8 
Rust :: armanriazi•rust•trait•object•safe 
Rust :: rust tuple vs vec 
Lua :: roblox how to make rainbow part 
Lua :: luau how to make region3 
Lua :: roblox make debounce 
Lua :: conda find package version 
Lua :: lua gsub 
Lua :: lua json 
Lua :: roblox lua wait for player to load 
Lua :: lua empty table 
Lua :: for loop in robox 
Lua :: How to make a working gun in lua code 
Lua :: lua run string as code 
Matlab :: matlab rlocus 
Matlab :: odd even in array matlab 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =