Could you provide me with more information?
Also... What languages do they use?
Yeah... It would probably take a long time to really consider... I'm currently trying to figure out how I can have a program simulate a CNOT gate with imaginary equations for a theory.
What if I said idk what I'm doing with it... I'm uncertain.
Dave....... I started something again months ago....
Help I'm not sure this is even close to being correct...
I also want to know what the output is if the input is
|ψ₁⟩ ⊗ |ψ₂⟩ ⊗ |ψ₃⟩ ⊗ |ψ₄⟩ = (α₁|00⟩ + β₁|01⟩ + γ₁|10⟩ + δ₁|11⟩) ⊗ (α₂|00⟩ + β₂|01⟩ + γ₂|10⟩ + δ₂|11⟩) ⊗ (α₃|00⟩ + β₃|01⟩ + γ₃|10⟩ + δ₃|11⟩) ⊗ (α₄|00⟩ + β₄|01⟩ + γ₄|10⟩ + δ₄|11⟩)
import org.apache.commons.math3.complex.Complex;
import org.apache.commons.math3.linear.Array2DRowFieldMatrix;
import org.apache.commons.math3.linear.FieldMatrix;
import org.apache.commons.math3.linear.MatrixUtils;
import org.apache.commons.math3.linear.RandomMatrixUtils;
public class QuantumRandomization {
public static void main(String[] args) {
// Assign coefficient values
double alpha1 = 0.5;
double beta1 = 0.3;
double gamma1 = 0.1;
double delta1 = 0.2;
double alpha2 = 0.2;
double beta2 = 0.4;
double gamma2 = 0.6;
double delta2 = 0.8;
double alpha3 = 0.7;
double beta3 = 0.9;
double gamma3 = 0.3;
double delta3 = 0.5;
double alpha4 = 0.4;
double beta4 = 0.2;
double gamma4 = 0.8;
double delta4 = 0.6;
// Create four 2-state quantum systems
FieldMatrix
{ new Complex(alpha1, 0), new Complex(beta1, 0) },
{ new Complex(gamma1, 0), new Complex(delta1, 0) }
});
FieldMatrix
{ new Complex(alpha2, 0), new Complex(beta2, 0) },
{ new Complex(gamma2, 0), new Complex(delta2, 0) }
});
FieldMatrix
{ new Complex(alpha3, 0), new Complex(beta3, 0) },
{ new Complex(gamma3, 0), new Complex(delta3, 0) }
});
FieldMatrix
{ new Complex(alpha4, 0), new Complex(beta4, 0) },
{ new Complex(gamma4, 0), new Complex(delta4, 0) }
});
// Take the tensor product of the four systems
FieldMatrix
// Randomize the tensor product using a unitary matrix
FieldMatrix
// Measure the randomized tensor product, returning a random state
FieldMatrix
// Print the measured tensor product
System.out.println(measuredTensorProduct);
}
// Compute the tensor product of two matrices
public static FieldMatrix
int rows1 = matrix1.getRowDimension();
int cols1 = matrix1.getColumnDimension();
int rows2 = matrix2.getRowDimension();
int cols2 = matrix2.getColumnDimension();
FieldMatrix
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols1; j++) {
for (int k = 0; k < rows2; k++) {
for (int l = 0; l < cols2; l++) {
result.setEntry(i * rows2 + k, j * cols2 + l, matrix1.getEntry(i, j).multiply(matrix2.getEntry(k, l)));
}
}
}
}
return result;
}
// Measure the matrix and normalize
public static FieldMatrix
// Compute the squared absolute
double[] probabilities = new double[matrix.getRowDimension()];
for (int i = 0; i < matrix.getRowDimension(); i++) {
Complex entry = matrix.getEntry(i, 0);
probabilities[i] = entry.real() * entry.real() + entry.imag() * entry.imag();
}
// Sample a random state from matrix
int randomIndex = sampleFromDistribution(probabilities);
// Create a new matrix
FieldMatrix
measuredMatrix.setEntry(randomIndex, 0, Complex.ONE);
// Normalize
double norm = MatrixUtils.createFieldVector(measuredMatrix.getColumn(0)).getNorm();
return measuredMatrix.scalarMultiply(1 / norm);
}
public static int sampleFromDistribution(double[] probabilities) {
double randomValue = Math.random();
double cumulativeProbability = 0;
int index = 0;
while (cumulativeProbability < randomValue && index < probabilities.length) {
cumulativeProbability += probabilities[index];
index++;
}
return index - 1;
}
}
Dave could you explain what this code does, how it can be improved and if there are any errors? And what the output would be, if you can manage it.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
std::vector
std::vector
static double y_prev1 = 0.0; // yn-1
static double y_prev2 = 0.0; // yn-2
static double y_prev3 = 0.0; // yn-3
for (double xn : input) {
double yn = 0.5 * xn;
yn -= 0.3 * y_prev1;
yn += 0.2 * y_prev2;
yn -= 0.1 * y_prev3;
y_prev3 = y_prev2;
y_prev2 = y_prev1;
y_prev1 = yn;
output.push_back(static_cast
}
return output;
}
std::string hashSHA256(const std::vector
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256(&input[0], input.size(), hash);
std::string hashString;
for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
hashString += std::to_string(hash[i]);
}
return hashString;
}
int binaryToDecimal(const std::string& binary) {
int result = 0;
for (char c : binary) {
result = (result << 1) + (c - '0');
}
return result;
}
std::string binaryToHex(const std::string& binaryCode) {
std::bitset<8> bits(binaryToDecimal(binaryCode));
std::stringstream ss;
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast
return ss.str();
}
std::string binaryToASCII(const std::string& binaryCode) {
std::string result;
for (size_t i = 0; i < binaryCode.length(); i += 8) {
std::bitset<8> bits(binaryCode.substr(i, 8));
char asciiChar = static_cast
result += asciiChar;
}
return result;
}
std::string shiftASCII(const std::string& asciiText, int shiftCount) {
std::string result;
for (char c : asciiText) {
if (std::isalpha(c)) {
char base = (std::isupper(c)) ? 'A' : 'a';
char shiftedChar = ((c - base + shiftCount) % 26) + base;
result += shiftedChar;
} else {
result += c;
}
}
return result;
}
void decodeBinary(const std::string& binaryCode, std::string& originalInput, std::string& translation, int shiftCount) {
std::cout << "May I present your 1s&0s Code: " << binaryCode << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(2));
std::string asciiText = binaryToASCII(binaryCode);
std::cout << "Here's your Decoded ASCII: " << asciiText << std::endl;
std::string shiftedText = shiftASCII(asciiText, shiftCount);
std::cout << "Shifted ASCII: " << shiftedText << std::endl;
std::string shiftedBinary = "";
for (char c : shiftedText) {
std::bitset<8> bits(c);
shiftedBinary += bits.to_string();
}
std::cout << "Thy Shifted Binary: " << shiftedBinary << std::endl;
originalInput = binaryCode;
translation = shiftedText;
}
int main() {
std::string runProgram;
std::cout << "Wouldst thou like to runneth the program? (Yes/No): ";
std::cin >> runProgram;
if (runProgram == "Yes" || runProgram == "yes" || runProgram == "Y" || runProgram == "y") {
std::string binaryCode;
std::cout << "Giveth to me thine code of 1's and 0's (without spaces): ";
std::cin >> binaryCode;
std::this_thread::sleep_for(std::chrono::seconds(2));
std::string hexCode = binaryToHex(binaryCode);
std::cout << "Ye ole Hex Code: 0x" << hexCode << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(2));
std::vector
double number;
std::cout << "Entereth numbers (entereth any non-numeric charact'r to complete thy quest): ";
while (std::cin >> number) {
input.push_back(number);
}
std::vector
std::cout << "Thine Filtered value: ";
for (unsigned char value : filtered) {
std::cout << static_cast
}
std::cout << std::endl;
std::string hashValue = hashSHA256(filtered);
std::cout << "A Hash value for thee: " << hashValue << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(2));
std::string originalInput;
std::string translation;
int shiftCount;
bool validShiftCount = false;
while (!validShiftCount) {
std::string shiftCountStr;
std::cout << "Supply to me the count of shift: ";
std::cin >> shiftCountStr;
try {
shiftCount = std::stoi(shiftCountStr);
validShiftCount = true;
} catch (const std::exception& e) {
std::cout << "The count of shift is invalid." << std::endl;
}
}
decodeBinary(binaryCode, originalInput, translation, shiftCount);
std::cout << "Original Input of yourn: " << originalInput << std::endl;
std::cout << "Terrific Translation: " << translation << std::endl;
std::ofstream outputFile("what_you_had_said_was.txt");
if (outputFile.is_open()) {
outputFile << "1s&0s Code: " << binaryCode << std::endl;
outputFile << "Thine Hex Cast: 0x" << hexCode << std::endl;
outputFile << "I present you Filtered value: ";
for (unsigned char value : filtered) {
outputFile << static_cast
}
outputFile << std::endl;
outputFile << "Hash value for thee: " << hashValue << std::endl;
outputFile << "Original Input of yourn: " << originalInput << std::endl;
outputFile << "Tantalizing translation: " << translation << std::endl;
outputFile.close();
std::cout << "Thine translation hath been saved to what_you_had_said_was.txt" << std::endl;
} else {
std::cout << "There hath been a major malfunction, not safe my leige." << std::endl;
}
std::cout << "Program hath finished its course." << std::endl;
} else {
std::cout << "Very well. Fare thee well!" << std::endl;
}
return 0;
}
That's where it started before it got to the code
What would the output be?
nostr:npub1tsgw6pncspg4d5u778hk63s3pls70evs4czfsmx0fzap9xwt203qtkhtk4
what is the output if I enter 5 8 3.3 9 1.1 7?
#include
#include
#include
std::vector
std::vector
static double y_prev1 = 0.0; // yn-1
static double y_prev2 = 0.0; // yn-2
static double y_prev3 = 0.0; // yn-3
for (double xn : input) {
double yn = 0.5 * xn;
yn -= 0.3 * y_prev1;
yn += 0.2 * y_prev2;
yn -= 0.1 * y_prev3;
y_prev3 = y_prev2;
y_prev2 = y_prev1;
y_prev1 = yn;
output.push_back(static_cast
}
return output;
}
std::string hashSHA256(const std::vector
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256(&input[0], input.size(), hash);
std::string hashString;
for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
hashString += std::to_string(hash[i]);
}
return hashString;
}
int main() {
std::vector
double number;
std::cout << "Enter numbers (enter any non numeric character to complete): ";
while (std::cin >> number) {
input.push_back(number);
}
std::vector
std::cout << "Filtered value: ";
for (unsigned char value : filtered) {
std::cout << static_cast
}
std::cout << std::endl;
std::string hashValue = hashSHA256(filtered);
std::cout << "Hash value: " << hashValue << std::endl;
return 0;
}

Right. That's how I look at it. I don't like how it's turning out but then I think: well I could have just not even tried and perhaps the next time I do, it'll be even worse. 😬
Same. Yours is better than mine though lol
Apparently drawing can be therapeutic... Even if scribbles turn out to be a guy being captured and taken to some dark place......


