VBA calculating with strings - arrays

I am quite new to vba coding. I have written a code which reads some data generates a matrix and a vector inverts the matrix and then multiples the inverted matrix with the vector, so nothing big. But now I want that the elements of the matrix and vector are strings or symbols. I hope that i will be able to get a more general solution. Is this somehow possible? Both objects are arrays.
The stringe i use do not have numerical values. In other words I am looking for a oppertunity to calculat with symbols like an algebra program like mathematica or maxia does.

Related

2D Math Matrix with Malloc

I know a similar question is already asked here for example:
Malloc a 2D array in C
However, my question is not how to create one but rather if I should prefer to use for a mathematical 2D matrix a "real" 2D array (with pointers of pointers) or rather a flattened 1-dimensional array with proper indexing.
I think the only case it can be important is when you are doing operations that depends on the neighbors of the matrix. In this case, using a 2D matrix is a bit better because it avoids cache misses.
This is specially important for problem solutions that use dynamic programming optimization .
I believe it can also be important for image processing, where many operations are applied in a rectangle of pixels.

Is there any Fortran function to transpose 3D array?

I need to transpose a 3D matrix in Fortran. I have a 3d array: V(111,222,333); I need to transpose it to V(333,111,222). Is there any function to do that in Fortran?
I hesitate to disagree with #IanBush and perhaps what follows is neither easy nor clear. The following statement will return a permutation of the array V. If I have got it right then the element at V(i,j,k) is sent to V_prime(k,i,j).
V_prime = RESHAPE(source=V, shape=[size(V,3),size(V,1),size(V,2)], order=[2,3,1])
Whether this creates the permutation OP asks for is a bit unclear, I'm not aware that there is a single definition of the transpose of an array of rank other than 2. Changing the order will produce different permutations.
This question is probably a duplicate of Fortran reshape - N-dimensional transpose. It is certainly worth reading the answers to that question which explain the use of reshape with order very well.
There is no routine that will do this simply. I would write some loops, that is often the easiest and clearest way.

What code is responsible for adding two matrices in Numpy?

I'm writing a program in C that adds two matrices (I'm also using BLAS). I want to see how this is done in numpy, to make sure I do matrix addition efficiently:
https://github.com/numpy/numpy
Can anyone help me find the C source code in numpy Github repository that does matrix addition?

Automated sparse matricies in Fortran

I know that Intel Fortran has libraries with functions and subroutines for working with sparse matricies, but I'm wondering if there is also some sort of data type or automated method for creating the sparse matricies in the first place.
BACKGROUND: I have a program that uses some 3 & 4 dimensional arrays that can be very large in the first 2 dimensions (~10k to ~100k elements in each dimension, maybe more). In the first 2 dimensions, each array is mostly (95% or so) populated w/ zeroes. To make the program friendly to machines with a "normal" amount of RAM available, I'd like to convert to sparse matricies. The manner in which the current conventional arrays are handled & updated throughout the code is pretty dependent on the code application, so I'm looking for a way to convert to sparse matrix storage without significant modification to the code. Basically, I'm lazy, and I don't want to revise the entire memory management implementation or write an entire new module where my arrays live and are managed. Is there a library or something else for Fortran that would implement a data type or something so that I can use sparse matrix storage without re-engineering each array and how it is handled? Thanks for the help. Cheers.
There are many different sparse formats and many different libraries for handling sparse matrices in Fortran (e.g. sparskit, petsc, ...) However, none of them can offer that compact array handling formalism, which is available in Fortran for intrinsic dense arrays (especially the subarray notation). So, you'll have to touch your code at several places, when you want to change it to use sparse matrices.

load NxNxN fortran binary matrix into matlab and retaining same ijk ordering

If I write out a fortran NxNxN array in binary then read it back into matlab and use
array = RESHAPE(inputdata,[N N N])
will it retain the same structure? i.e. will array(i,j,k) in Matlab correspond to array(i,j,k) in Fortran? Or do I have to change the ordering? Thanks.
Matlab and Fortran both use column-major storage order, so if you just did something like write(iounit) array, the example you posted should be fine as is.

Resources