# Tensor Multiplication

In this article we continue our quick start series. We assume that you are following from the previous article.

#### 5. Create a Compute Request for Matrix Multiplication

We will create a `ComputeRequest` to perform homomorphic matrix multiplication.

```cpp
    // Create operands for the compute request
    ComputeRequest::ComputeOperationOperand operand1(
        ComputeRequest::DataType::TENSOR,
        ComputeRequest::DataEncrytionType::CIPHERTEXT,
        serialized_ct1
    );

    ComputeRequest::ComputeOperationOperand operand2(
        ComputeRequest::DataType::TENSOR,
        ComputeRequest::DataEncrytionType::CIPHERTEXT,
        serialized_ct2
    );

    // Define the compute operation instance
    ComputeRequest::ComputeOperationInstance operation(
        ComputeRequest::ComputeOperationType::BINARY,
        ComputeRequest::ComputeOperation::MULTIPLY,
        { operand1, operand2 }
    );

    // Create the compute request
    ComputeRequest req(operation);
```

**Explanation:**

* We create two `ComputeOperationOperand` objects representing the serialized tensors.
* We specify that the data type is `TENSOR` and the encryption type is `CIPHERTEXT`.
* We define a `ComputeOperationInstance` for the multiplication operation with two operands.
* The `ComputeRequest` is created with this operation instance.

#### 6. Send the Compute Request and Receive the Response

We send the request to the network and receive the encrypted result.

```cpp
    // Measure the start time
    auto start = std::chrono::high_resolution_clock::now();

    // Perform the computation
    ComputeResponse* res = nullptr;
    client_node.compute(req, &res);

    // Measure the end time
    auto stop = std::chrono::high_resolution_clock::now();

    // Check if the computation was successful
    if (res && res->status() == ComputeResponse::Status::OK) {
        std::cout << "Encrypted result tensor received." << std::endl;
    } else {
        std::cerr << "Computation failed." << std::endl;
        return 1;
    }
```

**Explanation:**

* We measure the time before and after the computation to calculate the duration.
* The `compute` method sends the request and populates the `res` pointer with the response.
* We check the `status` of the response to ensure the computation was successful.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openvector.gitbook.io/docs/quick-start/editor-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
