My struct is ok, atleast with just complex numbers. I can't figure out how to get my array's to hold complex numbers
Type: Posts; User: bchudomelka
My struct is ok, atleast with just complex numbers. I can't figure out how to get my array's to hold complex numbers
microsoft visual studio express 2010 doesn't have complex.h
like....
void printcmplxmtrx(A[2][2]){
printf("A[1][1]=%lf+%lf*i", a.r, a.i);
.
.
.
}
Alright, I've been working on complex numbers, and I have the structure for it...
struct cmplx {
double r;
double i;
};
Now, if I wanted to make a matrix with cmplx numbers, could I...
I got the code to work. Thanks everyone for your help.
...uh...oops.
I got it to work. Thanks. Right now, I'm having a problem divinding by a friggin' integer... the first section of code is my factorial func
int factorial(int k){
if (k==0){return 1;}
int...
I am passing sigma_x[2][2] into expm()... i.e. expm(sigma_x).
then it's job after that is to compute sigma_x^n. then it prints out the result then returns back to main.....
so
for (int i =...
I've ran into another wall. Ouch... I've created A^n for the taylor expansion, but the answer is in a func which is not in main. How do I take the result of A^n and map it to something usable in...
Got the function. This is the code.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void multmtrx(int A[2][2], int *B, int *result)
{
for (int i=0; i<2; i++){
Yes!!! Thanks!!! Awesome!!! I have a follow up question...so now I have this main func that does A^n. To turn this into a func called expon...
Hypothetically, I would..
int expon (int...
I'm lost. I see that by defining temp to be all zeroes, then it just outputs a zero matrix. Whatever I define temp as in main, that is what's returned. I'm not following your suggestions so well.
Like this?
do {
temp = (int*)malloc(sizeof(int) * 4);
temp[0] = 0;
temp[1] = 0;
temp[2] = 0;
temp[3] = 0;
Now the func doesn't do anything. Should I change void to int and return result or some other matrix? Then printmtrx(result);
I am actually trying to reset the counter. So it does the multmtrx op again from scratch. I tried to move it to a func.
void expon(int A[2][2], int m)
{
int *temp;
temp =...
I'm sure there's a slick way to do it. I'm not there yet in my skills. Currently, I'm just working on developing a taylor series for the expm[A]. Once that works, I'll try to develop some structure...
Sorry, this code isn't right. I've done some editing and this is now the correct code.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void multmtrx(int A[2][2], int *B, int...
Got it! Thanks!
I have some code here to multiply matrices. It's not working as designed. Any suggestions? I want it to multiply a matrix then continue to do so until it reaches n. So, the desire output is A^n,...
ii=i;
%Pauli ops
sx=[0,1;1,0];
sz=[0,0;0,1];
%Number of steps, define time slice
dt=T/N;
%Physical parameters
How do I map values to the elements then?
for (i=0; i<nrows; i++)
for (j=0; j<ncolumns; j++)
array2d[i][j]=0;
?
This is an example I create with the code you gave.
#include <stdio.h>
#include <stdlib.h>
int main(){
int k;
int col = 10;
int row = 10;
int *array1d;
I'm trying to convert some matlab code into C for a qubit simulation. So, I'm trying to create the taylor series for the time evolution operator. How could I get a function like:
printf("How many...
Thanks so much. I was able to create the malloc. It's starting to make more sense.
So, the int **array1 assigns the array1 pointer to be of int type? malloc allocates the memory of the nrows in the 1st instance? the for loop causes array element i to be allocate the memory for...