> For the complete documentation index, see [llms.txt](https://openvector.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openvector.gitbook.io/docs/quick-start/editor-2.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
